MATLAB
MATLAB Examples


MATLAB is a directory of MATLAB programs which illustrate the use of the MATLAB interactive programming environment.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Data and Programs:

F90_MATLAB, MATLAB functions which are called by a FORTRAN90 program.

MATLAB_C, MATLAB programs which call a C function using the MEX facility.

MATLAB_COMMANDLINE, MATLAB programs which illustrate how MATLAB can be run from the UNIX command line, that is, not with the usual MATLAB command window.

MATLAB_F77, MATLAB programs which call a FORTRAN77 function using the MEX facility.

MATLAB_MOVIES, MATLAB programs which generate animations.

MATLAB_OS, MATLAB programs which invoke an operating system command.

MATLAB_RANDOM, MATLAB programs which illustrate the use of Matlab's random number generators.

Source Code:

CPU_TIMING shows how you can measure the CPU time required for a given computation.

FACTORIAL uses the standard example of the factorial function to demonstrate MATLAB's ability to implement a recursive function.

HELLO is a simple example to print out "Hello, world!".

HELLO_ITHACA_QUEUE shows how the "Hello" program can be run on the Ithaca cluster.

PERSIST shows how a persistent variable can be used to "remember" the value of some variable within a function between calls.

RECURSIVE_TEST shows how you can use recursion in a function definition.

SPACING_MATTERS demonstrates that MATLAB can fail to interpret an arithmetic statement correctly because of the occurrence of a blank space. This occurs when creating a vector by listing entries. MATLAB allows the lazy practice of not separating entries by commas, and the result can be an error that is very hard to interpret.

STARTUP is a MATLAB script that can be used to initialize MATLAB. You have to know where to put it, though. (Hint: start MATLAB, and type "pwd" to find out where MATLAB starts by default. That's where you want to put this file.)

You can go up one level to the MATLAB source codes.


Last revised on 01 April 2011.