Connect Fall 1996:  SCIENCE AND VISUALIZATION


Matlab: A Powerful Tool in Scientific Computing

Hua Chen

[Ed: Links to web pages and/or e-mail addresses which have become inactive since the publication of this article have been enclosed in curly brackets { }. Replacement links have been provided where possible.]

Matlab—for Matrix Laboratory—is a high-level programming environment for mathematical and scientific computation widely used in academia and in industry. The Matlab system derives much of its computing power from two core components. The first is a package of high-quality numerical linear-algebra routines. From the start, there has been a close and continuous association between Matlab and scientific-computing researchers. As a result, many state-of-the-art numerical algorithms have been incorperated into the Matlab system.

The second component crucial to the performance of Matlab is its graphics compatibility. The 2D and 3D graphics of Matlab are based on the geometric representation of matrices and vectors, hence it works seamlessly with the rest of the system.

From this highly optimized core of mathematics and graphics, Matlab is further extended by a family of application-specific packages called toolboxes. Each toolbox contains a collection of Matlab scripts (called m-files) and programs written in Fortran and C (with Matlab interface). Over the years, MathWorks and others have developed toolboxes with applications ranging from numerical analysis and statistics to neural nets, fuzzy logic, and financial modeling (see "Matlab Toolboxes" for an extensive list). This dynamic development process has made Matlab an ever-expanding software system, reflecting ideas and efforts of leading researchers and practitioners in many fields of science and engineering.

This high-performance computing engine is complemented by a user-friendly programming environment. The user interface of Matlab is command-driven and interactive. The basic data objects such as matrices and vectors can be easily constructed and manipulated in a functional syntax that is close to the way it is done on paper. Since many problems can be solved with a simple one-line procedure call or function call, Matlab can be used quite effectively without resorting to extensive code writing. Matlab has its own high-level programming language, which the system interprets. Therefore it is much easier to program in it than in many common lower-level languages such as Fortran, Pascal, or C, since the programmer can concentrate on the logic and the efficiency of an algorithm without being burdened by issues such as variable declaration and memory allocation. Of course, this ease of use comes at a price. As with many interpreted languages, there is often a performance penalty in running time, especially if the program is dominated by loops. However, in most cases, this extra time needed to run the program (possibly up to ten times as much) is more than offset by the amount of time saved in programming (by a factor of 10-100).

For projects in which performance is the overriding objective, there are two ways to achieve run-time efficiency within the Matlab programming environment. The first is to use the Matlab compiler, which translates an m-file into C code and generates a Matlab callable binary file (called a mex-file). The more traditional method is to optimize the script by vectorization—which means to convert iterative operations on scalar data into matrix operations on matrix objects.

This flexible and intuitive programming environment has made Matlab a powerful development tool. For example, a new user with basic knowledge in linear algebra can start to write concise, easy-to-understand, and very efficient codes within weeks. An experienced Matlab user, with sufficient understanding of the underlying mathematics of a particular field of application, can build a customized environment with new commands and new toolboxes.

Because of this powerful combination of a user-friendly development environment and a high-performance numerical-computing kernel, Matlab has became the software of choice for thousands of scientists and engineers around the world.

The choice of mathematics software for an individual user, however, depends to a great extent on the field of application. For example, Mathematica may be a better general-purpose mathematical-computing system; and Maple is regarded as the leading software for symbolic computing. We hope to have similar discussions about these systems in the coming issues. Further information about Matlab can be found online at http://www.mathworks.com/ . [ C ]


Hua Chen was a systems administrator with the ACF Science and Visualization Group at the time of this article's publication.
{chenhu@nyu.edu}

Posted 26 September 1996; revised 30 November 2005