Matlab

Description
MATLAB is an interactive, matrix-based language for technical computing that allows easy implementation of statistical algorithms and numerical simulations. Highlights of MATLAB include the number of toolboxes (collections of programs to address specific sets of problems) available. The disadvantage of MATLAB is that it tends to use a significant amount of memory and it is relatively slow in executing if-statements and for- and while-loops that cannot be vectorized.

Availability

Northwestern servers: MATLAB for Linux is currently available in Kellogg's UNIX server, Skew, as well as SSCC and Quest. To start MATLAB, type matlab at the command prompt. 

Lab computers: MATLAB is installed on 16 machines at the Kellogg Lab Computers.

Personal computers: MATLAB is available for faculty, students, and staff on a cost-sharing basis; for Windows, Mac, and Linux, see the NUIT MATLAB page for details. There are 3 types of licenses available; they vary in cost and toolbox availability:

  • Concurrent license: this license requires the computer to be on the Northwestern network, either through a wired or wireless connection, or through VPN. It is particularly suitable for office desktops, but can be used on other computers, as long as an Internet and VPN connection is available. It has the largest selection of toolboxes. All licenses are for the academic year and expire every September.
  • Group license: this license does not require the computer to be connected to the Internet. It has a very small selection of toolboxes and also requires annual renewal. It is only available to tenured and tenure-track faculty.
  • Student TAH license: this license is available to all Northwestern students. It has a slightly smaller toolbox selection than the Concurrent license but much larger than the Group license. It does not require annual renewals and is valid for as long as the student stays with Northwestern.

Concurrent and Group licenses are administered by KIS, while students can purchase licenses for their laptop or home computers through the NUIT site. Academic departments who wish to purchase Student licenses through a Northwestern chart-string account should contact Alan Wolff at McCormick.

Vendor Information 
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098
Phone: (508) 647-7000

Support
The MathWorks web pages offer several support options:

Running MATLAB

UNIX:
To start MATLAB in UNIX (either in a terminal or in a X-Windows session), type "matlab" at the prompt. To run a MATLAB m-file in "batch," use the UNIX redirection symbol ("<"). For example: matlab < filename.

MATLAB reads each line of filename.m as if it was typed by the user at the MATLAB prompt.

To end the MATLAB session, type quit at the MATLAB prompt (">>"). If you do not exit the program properly (i.e., if you quit by closing the Xterm or telnet session rather than typing "quit"), the MATLAB session does not end. It continues to use memory and CPU.

When running time-consuming M-files, it may be desirable to run MATLAB in the background in order to work on something else or to log out of the computer. To run MATLAB in the background, type the following command at the UNIX prompt: nohup matlab < file.m > output &, where "file.m" is the M-file to be executed and "output" is the file to which the output will be sent. Note that the output file contains everything that would be printed on the screen if you were to run your job in interactive mode. In most cases, it only contains debugging messages and does NOT contain the results of your program. You need to include the save command in your program to save the results to a physical file. If you are not interested in saving the output, you may specify /dev/null in the place of output.
The following example shows what it looks like:

>nohup matlab < test.m > /dev/null &
[1] 7414 

[1]+ Done nohup matlab /dev/null

Microsoft Windows and Mac:
MATLAB under Windows runs and ends as any other Windows application. The "quit" command from the MATLAB prompt will work, too.

Examples and Solutions

User Contributed M-Files:

MATLAB Central File Exchange

Improving the performance of a program: There are several tools and options to improve a program's performance.

    See also the MATLAB page at the University of Cambridge for more tips on optimizing your code.

MEX-files: Bottleneck computations (usually for and while loops) can be recoded in C or Fortran to run much faster than in MATLAB. MEX-files also allow MATLAB to access existing C or Fortran routines without rewriting them. For reference, see:

MATLAB Wiki F.A.Q. 

Sample programs at Kellogg

Numerical Computing with MATLAB by Cleve Moler (Mathwork's Chief Scientist and founder), 2004

Useful Links