
The ECN No Name Newsletter is no longer being published. This is an archived issue.
[previous article] [next article]MATLAB is a mathematical analysis package now available on all Suns and many Macintoshes on the ECN. MATLAB stands for MATrix LABoratory. It is very useful in performing tasks involving linear algebra-like digital signal processing and control simulations. It is a simple interpretive language that works in a command line fashion. MATLAB for the Macintosh is very similar to Sun MATLAB, also known as PRO-MATLAB. The sample MATLAB session shown above is on a Sun Workstation.
This article will attempt to give an overview of MATLAB's capabilities. In order to learn how to use these capabilities, one should obtain a MATLAB User's Guide from the Potter Library. These are available at the reserve desk for a loan of up to three days. The User's Guide provides a very complete tutorial which is easy to understand.
As mentioned above, MATLAB is a powerful linear algebra package. Entering and manipulating vectors and matrices is simple. Complete "programs" can be built in matlab to simulate complete systems in much less time than it would take to hard code them into C or FORTRAN. Additionally, MATLAB already provides many functions commonly used in Engineering including those listed below.
The graphing capabilities are especially useful in visualizing data as it is being processed. Some of these graphic capabilities are shown below and on the next page.
sample charts
Many different types of plots can be obtained -- linear, logrithmic, semilogarithmic, polar, three dimensional, and bar chart. All of these allow different line and point types and colors. Additionally, if you are using a non-graphic terminal, you can use the plot commands exactly the same way as with graphic devices, the only difference is that you have to dump your "imaginary" screen to a printer.
The signal processing capabilities allow for operations like FFTs and 2-D FFTs, frequency shifts, convolution, deconvolution, filtering, Laplace and Z transforms, just to name a bunch. More information is available on these and many more specialized functions in the MATLAB User's Guide.
Another capability within MATLAB allows users to write their own functions, called M-files, so that they can customize MATLAB to their needs. If a user had the need for the sinc function displayed in the above example session, he could write an M-file to perform that function. He would no longer have to type it in line by line. M-files can also be used to make one big function that can be used like a program.
Starting MATLAB up is simple. One simply types matlab at the UNIX prompt on the Suns or clicks the MATLAB icon on the Macintoshes. If he is logged in at the Sun console and running a window system like Suntools or X11, a second window will appear to display MATLAB plots. Similarly, two windows will appear on the Mac, one being the command window and the other being the graphics window. Typing "demo" at the MATLAB >> prompt will run a menu-driven demonstration program which highlights many of MATLAB's features. Typing "help" will give the user a number of lists of all MATLAB functions. It is also possible to type "help function-name" to get information about the use of that function.
In addition to the standard MATLAB program, ECN has obtained a number of "toolboxes" from The MathWorks, Inc. These contain specialized functions for advanced signal processing, parametric and non-parametric modeling methods, control simulations, chemometrics, and spline construction. These toolboxes each have their own special manual, which is also available from the Potter Library. These also have their own demonstration programs to illustrate their capabilities. All of these toolbox functions are listed in MATLAB's help file.
MATLAB is indeed a very powerful package, however, it is still interpretive. This means MATLAB reads the user's code and then executes a specific sequence of instructions. This process is very slow compared to if the user had written the program in C or FORTRAN. What this means is that MATLAB is great for short one- shot programs, plotting large sets of numbers, or trying out specific algorithms. However, it is not good for long simulations and number crunching. The approach one should take is to try an algorithm out with MATLAB and then code it into C or FORTRAN to use for the long term. Many of the functions in MATLAB and its toolboxes are available in other packages on ECN like IMSL.