MATLAB

From Exampleproblems

Jump to: navigation, search

MATLAB refers to a numerical computing environment and its core programming language. Created by The MathWorks, MATLAB allows easy matrix manipulation, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs in other languages. Although it specializes in numerical computing, an optional toolbox interfaces with the Maple symbolic engine, making it a full computer algebra system. It is used by more than one million people in industry and academia and runs on most modern operating systems, including Windows, Mac OS, Linux and Unix. The current version is MATLAB 7.1 Service Pack 3. It is available for commercial use for approximately US$2000 and US$100 for an academic license with a limited set of Toolboxes.

Contents

History

Short for "MATrix LABoratory", MATLAB was invented in the late 1970s by Cleve Moler, then chairman of the computer science department at the University of New Mexico. He designed it to give his students access to LINPACK and EISPACK without having to learn Fortran. It soon spread to other universities and found a strong audience within the applied mathematics community. Jack Little, an engineer, was exposed to it during a visit Moler made to Stanford University in 1983. Recognizing its commercial potential, he joined with Moler and Steve Bangert. They rewrote MATLAB in C and founded The MathWorks in 1984 to continue its development. These rewritten libraries were lovingly known as JACKPAC. MATLAB was first adopted by control design engineers, Little's specialty, but quickly spread to many other domains. It is now also used in education, in particular the teaching of linear algebra and numerical analysis.

Example MATLAB code

This code, excerpted from the function magic.m, creates a magic square M for odd values of n.

[J,I] = meshgrid(1:n);
A = mod(I+J-(n+3)/2,n);
B = mod(I+2*J-2,n);
M = n*A + B + 1;

Note that this code performs operations on vectors and matrices without the use of "for" loops. Idiomatic MATLAB programs usually operate on whole arrays at a time. The MESHGRID utility function above creates arrays like these:

I = 1 1 1   J = 1 2 3
    2 2 2       1 2 3
    3 3 3       1 2 3

Most scalar functions can also be used on arrays, and will apply themselves in parallel to each element. Thus mod(2*J,n) will (scalar) multiply the entire J array with 2, before reducing each element modulo n.

MATLAB does include standard "for" and "while" loops, but it is almost always faster to write and execute code that expresses vector operations.

There are many other programs that do similar tasks to MATLAB; for a list, see the software section of the article on numerical analysis

Criticism

MATLAB itself is a proprietary product of The MathWorks. Unlike common programming languages such as C or FORTRAN, the MATLAB language is not managed or specified by a 3rd party standards committee such as ANSI. Obtaining a fully compatible and up to date MATLAB platform requires purchasing the product. Some programs are available that implement significant subsets of the MATLAB programming language (notably the free software GNU Octave project), but these are not 100% compatible and do not include various domain-specific tools.

MATLAB was originally written in FORTRAN and later re-written in C. The language shows this mixed heritage with a sometimes erratic syntax, not C, not FORTRAN, but combinations of both. This mixed syntax can lead to interpretation problems. For example, the expression:

   y = f(x)

could either refer to function f with argument x or the x value of matrix f. This ambiguity is difficult to resolve without closely examining the code. Similar difficulties surround the * and ' operators.

The basic data type in MATLAB is a matrix, an array of numbers devoid of important attributes required by real world data such as engineering units, sampling rates and time/date markers. Especially the lack of sample rate information is a serious shortcoming for signal processing applications, where data is typically sampled at a constant interval. These attributes must be managed by the user with custom programming, which is error-prone and time-consuming.

MATLAB is a procedural programming language, so it cannot automatically update variables in response to input changes as one might want for simulations or exploratory data analysis. Consider, for example, the following fragment:

  t = 1:100;
  y = log(t);

If variable t changes, e.g. t = 100:1000, the user must manually re-evaluate y to obtain the updated result. The MathWorks offers a supplementary package, Simulink, that partially automates these tasks for systems modeling and simulation applications.

Despite these shortcomings, MATLAB continues to be employed in many technical analysis applications, though several viable competitors are emerging.

See also

Toolboxes and other add-ons:

Alternative programs with (quite) similar syntax:

External links

Error creating thumbnail: lt-convert: unable to open image `/home/exampleproblems.com/wiki/images/6/6f/Wikibooks-logo-en.png': No such file or directory.
lt-convert: unable to open file `/home/exampleproblems.com/wiki/images/6/6f/Wikibooks-logo-en.png'.
lt-convert: missing an image filename `/home/exampleproblems.com/wiki/images/thumb/6/6f/Wikibooks-logo-en.png/50px-Wikibooks-logo-en.png'.
Wikibooks Programming has more about this subject:

es:MATLAB fa:متلب fr:Matlab it:MATLAB lt:MATLAB ja:MATLAB pl:MATLAB ru:MATLAB sv:MATLAB zh:MATLAB

visitor stats