# REVIEW OF MATLAB FOR WINDOWS VERSION 4.0 BY LOUIS MENDELSOHN

*By Lou Mendelsohn*

**THE MATH WORKS INC.**

Cochituate Place

24 Prime Park Way,

Natick, MA 01760

**Phone:** 508 653-1415

**Fax:**508 653-2997

**Product: **High-performance numeric computation and visualization software that provides an interactive graphical environment designed to integrate numerical analysis, matrix computation, signal processing and graphics.

**Equipment requirements:** 80386 or higher processor, Windows 3.1. 387 or 487 math coprocessor. Windows-supported mouse. 8 MB of free space on hard drive. 4 MB of extended memory (8 MB or more is required to use MATLAB 4.0 3-D color graphics and image processing capabilities).

Recommended equipment: At least 8 MB of RAM. 8-bit graphics adapter and display (to achieve 256 simultaneous colors), Microsoft Windows-supported graphics accelerator card and printer.

Other platforms: Apple Macintosh. Sun SPARC. DEC RISC. DEC ALPHA. SGI. HP9000 Series 300/400/700. IBM Rs/6000 and VAX/VMS, CONVEX and CRAY

Other operating systems: Macintosh, UNIX and VMS.

**Price:** $1,695

MATLAB (short for matrix laboratory) was originally designed to provide access to matrix analysis in an easy-to-use system. Through its continued evolution and the addition of more specific functional add-ons, MATLAB now provides an excellent platform for both academic and commercial applications, for students studying linear algebra and engineers performing research and solving practical engineering problems. With financial market analysts and traders beginning to embrace advanced technologies such as neural networks to perform nonlinear analysis and forecasting, development tools such as MATLAB should become popular in the financial industry.

MATLAB encompasses an extensive library of more than 500 mathematical, statistical, scientific and engineering functions. The basic data elements of MATLAB are matrices that do not require dimensioning. These matrices can be composed of real or complex numbers and can hold objects such as signals, images, polynomials, time histories, multivariate statistical data or linear systems. Once a user is familiar with the manipulation of these matrices, MATLAB’s interactive environment can help solve many problems intuitively in less time than would be necessary to write a program in a standard computer language.

In addition, for the more advanced user, MATLAB provides a set of programming constructs including the standard FOR, WHILE and IF statements along with ASCII (see sidebar, “Importing data into MATLAB”) and binary file input and output functions. Debugging features allow the user to insert breakpoints and single-step through functions while examining specified variables. With these programming constructs and debugging features, repeated activities can be written into reusable functions that provide the user with a very important benefit, extendibility. Since MATLAB contains more than 20 categories of functions that can be further supplemented by 15 toolboxes of application-specific functions, the user can utilize them all to build additional custom functions.

Another important feature found in MATLAB and each MATLAB toolbox is the adherence to an open system. Source code is made available for most of the M-files designed to run in MATLAB. M-files are ASCII files that contain either MATLAB commands to be executed or functions. Making this information accessible allows the user to build upon what is already available and develop more elaborate research protocols by writing custom M-files. Existing M-files are also useful as examples to help new users learn MATLAB more quickly.

**GRAPHICS**

A discussion of MATLAB would not be complete without mentioning its graphics capabilities, which are an integral part of the environment. The user can graph formats such as logarithmic scales, polar plots, scientific notation, error bars and more. The graphics provide the user with a means of analyzing, transforming and visualizing data computed in the interactive environment. The object-oriented approach of the graphics in MATLAB allows the user to grab a handle to a graph and control almost any of its attributes. These attributes include color, font, shifting of axis direction or altering of tick length. The user can define or interactively change the attributes of a graph directly on the screen.

MATLAB has excellent graphics and data visualization. Figure I shows a two-dimensional cross-sectional model of an airplane wing with two trailing flaps surrounded by a triangular grid. Such a graph can be used to visualize flow over the surface of the wing.

Figure 2 is an example of how color can be used to add an extra dimension to a standard three-dimensional function plot. This is a representation for a complex valued function [f(z)=z] of a complex variable [f(z)]. The domain is the unit disc, displayed in polar coordinates. The real part is represented by the height of the surface, while the imaginary part is represented by the color of the surface.

Figure 3 illustrates the three-dimensional path of a portion of Earth during part of the Loma Prieta earthquake in the Santa Cruz Mountains on October 17, 1989. When viewing this graphic in MATLAB, the dot tracing the actual movement of the point along the path can be visualized.

Figure 4 depicts a three-dimensional topological map of the Earth, while Figure 5 shows a three-dimensional surface plot of a function using hot (represented by reds and yellows) color maps. Figure 6 shows a tubular surface surrounding a three-dimensional knot.

**USING MATLAB**

MATLAB runs via an interpreter. It is from the interpreter’s command line that the user interacts with MATLAB. At the beginning of a session, the command window appears and becomes the active window. The window is used to enter commands directly into the MATLAB interpreter by typing instructions at the prompt. When you press enter, the command is processed and its results are displayed immediately on the screen. In addition, the command window contains an editor that makes editing mistyped instructions as easy as editing a document in a word processor. The basic syntax in MATLAB, for manipulating matrices and performing standard mathematical computations, is relatively straightforward and only requires a few hours to learn.

Becoming familiar with MATLAB’S mathematical functions will, of course, take longer, due to sheer numbers. While some of MATLAB’s functions are built into the interpreter, others are stored in M-files. The M-files may contain normal MATLAB statements and references to other M-files. The user can use M-files both as scripts to automate long sequences of commands and as functions to expand MATLAB’s base function set. When using graphic functions, MATLAB displays the graphic output to a separate, automatically generated window. Subdividing the graphics window allows MATLAB to display multiple plots. Data is presented using a collection of graphics objects. The user can control the objects by setting the values of their properties. Color graphics can be created using tools such as surface rendering, wire frame, pseudo color, light sources, three-dimensional contours, image display, animation and volumetric visualization. The use of three- four- and even five-dimensional tools aid in understanding and studying, complex sets of data.

**MATLAB TOOLBOXES**

Currently, MATLAB has 15 toolboxes available targeting specific areas of math or science. These toolboxes provide functionality for applications such as stochastics, signal processing, automatic control system design, dynamic system simulation, parametric modeling, neural networks and optimization. MATLAB toolboxes install directly into the MATLAB environment, making their functions available to the user. Most of the features of the MATLAB toolboxes use programmable M-files, giving the user access to the source code and the algorithms, thus supporting the open-system philosophy.

Control engineers and system theorists will find that MATLAB can execute complex arithmetic, matrix inversion, eigen-value computations and root-finding. The Control System Toolbox extends MATLAB by providing tools specializing in control engineering. This toolbox can implement common control system design, analysis and modeling techniques. It works with four different types of system models, a set of conversion functions that allow models to convert between various representations including continuous-time and discrete-time, and provides functions for calculating time and frequency response.

For solutions to complex design problems, the Optimization Toolbox can be used to improve reliability and performance in a wide range of applications. Through MATLAB, a user can formulate cost functions and constraints and then solve them using the functions included in the toolbox. Immediate feedback facilitates the search for the best solution. Minimization and maximization can be performed on general nonlinear functions. In addition, other routines for linear programming, quadratic programming and nonnegative least squares are available. This toolbox may be of interest to traders and technical analysts, since linear and nonlinear optimization have found many applications in the financial industry.

The Signal Processing Toolbox contains tools for digital signal processing and time-series analysis and functions to perform digital filtering and power spectrum estimation. Of particular interest to market technicians might be the data analysis tools it provides for computing the discrete Fourier transform and other related spectral transformations, including one for trend removal.

The Neural Network Toolbox allows users from many different fields to understand and apply neural networks. (See the product review for MATLAB Neural Network Toolbox.) The user guide contains an introduction to neural networks and describes architectures, paradigms and training functions. This toolbox will probably be the one of most interest to market technicians, as it provides a means of exploring and performing financial forecasting with neural networks.

**SUMMARY**

MATLAB is an excellent environment for research and system development. Its interactive nature lets the user quickly and easily explore a variety of research options, while its data visualization capabilities allow the user to graphically visualize and interpret data in a wide variety of ways. Scientists, mathematicians and engineers have been using tools such as MATLAB for some time. As market analysts and traders continue to adopt methods from these disciplines to financial analysis and forecasting, additional uses will be found for tools like MATLAB in the financial industry.

*Louis Mendelsohn, 813 973-0496, Fax 813 973-2700, is President of Market Technologies, Wesley Chapel, FL., a research, software development and consulting firm involved in the application or artificial intelligence to financial market analysis.*

*Reprinted from Technical Analysis of
Stocks & Commodities magazine. (C) 1994 Technical Analysis, Inc.,
4757 California Avenue S.W., Seattle, WA 98116-4499, (800) 832-4642.*