Matthias K. Gobbert

This page is historic. For up-to-date information on MATLAB, please go to CIRC page on MATLAB



How to Get Started with Matlab at UMBC

Matlab Release R14 (Version 7.0)


This page can be reached via my homepage at http://www.math.umbc.edu/~gobbert.

Purpose of this Document

This document provides crucial information that tells you how to get started with Matlab on computer systems at UMBC. It will not tell you how to use Matlab, but rather, where to find the appropriate information to learn more.

Information like this is bound to change over the course of time, and that is the rationale behind making the information available on a webpage. Hence, note the information at the top of the page indicating Matlab's version and the semester, which this document was written last updated for. In response to feedback, I may update this page more often; look at the bottom for a more precise date.

You are welcome to tell others about this page and to create a link to it. Instead of providing a live link to this page, I suggest to link to my homepage like I have done above.

As always, I appreciate your comments and feedback about this page. However, please understand that I am not the answer box for Matlab questions as such on this campus. I am just trying to make my expertise available to the community so that everyone can get started successfully, but you will have to study the documentation yourself to actually solve your problem. If you are interested in a class on the subject, consider our Math 426, which is a basic but thorough introduction.


What is Matlab?

Matlab stands for Matrix Laboratory and was originally written as a teaching tool to support an introductory linear algebra class (like Math 221 at UMBC). Since that first version, it has been extended and upgraded to be one of the most versatile and popular packages for numerical computations and graphing. It is widely used in industrial companies, government agencies, and educational institutions for rapid prototyping and teaching. Its main popularity roots in its intuitive interactive interface combined with reliable numerical algorithms and professional graphics capabilities.

The above is my statement, based on using Matlab extensively since 1991 in the teaching of Numerical Analysis and in research involving computational simulations of a variety of application problems. For the official answer, check out http://www.mathworks.com, the webpage of the MathWorks, Inc., maker of Matlab.


Where Can I Use Matlab at UMBC?

UMBC maintains campus licences for Matlab (and its toolboxes) under the Unix/Linux, Windows, and Macintosh operating systems. The most efficient way to run Matlab is to use a lab PC and run it locally. You may also run it remotely on several of the gl systems. I am not familiar with Macintosh and Matlab on workstations at UMBC such as Sun or SGI cannot be recommended at present, so the following only addresses only Windows and Linux.

Starting Matlab under Windows

If you use Windows, start Matlab in the usual way from the Start menu, by expanding the menu on Programs, then MATLAB 7.0, and then clicking on MATLAB 7.0. The complete desktop should come up now. Matlab might remember whether you had other windows open at the end of your previous session, so the HelpBrowser (which might even open with the page you last visited) and other windows may open again.

At present (and this may change eventually), Matlab starts up in the folder C:\MATLAB7\work or similar; see the "Current Directory" box at the top of the desktop. This is a system folder on the local system and not writeable for a user. So, you must change directory in order to be able to save files later on. You can use the browse option (button saying "..." next to the current directory) for this, but let me use Matlab commands here for simplicity. You should change to the S: drive first by cd S:; this is the AFS area accessible from all systems at UMBC and over the internet. I suggest to create a folder for your project to work on: For instance, if you are a student in Math 426, you may want to create a folder for this class by mkdir Math426, then change into it by cd Math426. In turn, create a directory for each class or homework by, say, mkdir Homework1 and change to it by cd Homework1. Check what the "Current Directory" says or say pwd in the command window, which stands for "print working directory".

Starting Matlab under Linux

Under Linux, you need to get a command window (shell) first (for instance by clicking on the screen icon at the bottom of the screen). Then simply enter matlab at the prompt of the command window (and press return). For more information on command-line options, use matlab -h. Matlab might remember whether you had other windows open at the end of your previous session, so the HelpBrowser (which might even open with the page you last visited) and other windows may open again.

In the previous item on starting Matlab under Windows, I discuss in some detail how to change directory after starting Matlab. Under Linux, it makes more sense to change directory first, using the Unix/Linux commands mkdir and cd (and pwd and ls to inquire). Then, start Matlab in your desired directory which will make all files associated with your project accessible.

Running Matlab Remotely (Under Linux)

Usually, it is most effective and convenient to run Matlab locally, in particular for interactive work, but there are a number of reasons why you might want to run Matlab remotely across a network. For instance, your local machine may not have Matlab installed at all, or your local machine may not have sufficient memory for your task. In these cases, you can consider accessing another computer by remote login and running Matlab there. This concept only makes sense under Unix/Linux on the remote machine; Windows or Macintosh do not allow for remote access (as far as I know). Hence, for any new windows to be opened, also your local system needs to be Unix/Linux. However, the performance of such remote windows may be so slow that you will want to avoid them anyway and rather run Matlab purely inside your login shell; naturally, this precludes any graphical output and restricts this use to numerical tasks only.

So, we want to start Matlab (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by saying matlab -nodisplay. You could also use matlab -nodisplay -nojvm, which additionally does not start the JVM. In both cases, attempts to open plot and similar windows might be simply ignored or attempts to open the documentation windows might result in various error messages.

The above is the most restrictive way in which to start Matlab. If in fact your local machine is Linux, you could use matlab -nodesktop -nosplash, which (i) does not start the desktop and (ii) suppresses the splash screen (the small window with Matlab's logo and version number that usually pops up briefly). But this way of starting Matlab does start the JVM and you have access to the HelpBrowser as well as to plot windows, if you later so desire (and are willing to wait for those to open, which might take a while depending on your network connection).

Running Matlab in the Background (Under Linux)

The idea of running a job in the background means that a software runs without any user interaction and additionally does not block your login shell. As remote access, this makes only sense under Unix/Linux. It applies both on your local machine, but might be particularly useful on a remote login; as in the previous section, this will be most useful for purely numerical (i.e., non-graphical) jobs.

  nohup \matlab -nojvm -nodisplay < driver.m >& driver.log & 
Here, the backslash in \matlab circumvents any possible alias you might have for Matlab (just to be on the safe side) and the options -nojvm -nodisplay suppress the starting of the JVM (and the startup of the desktop) and the opening of any windows. The final ampersand ("&") actually puts the command into the background, i.e., gives you the command-line prompt in your shell back. Aside from entering any usual commands now, you could in particular log out, without hanging or killing your job, because of the standard Unix/Linux command nohup before the call to Matlab. The file driver.m that must be present in the current directory is a Matlab script file (not: function file) that lists the commands to be executed by your job; if your job is actually performed by a function, this script file can simply be a single line that calls your function.

For the remaining elements in the command-line above, I am assuming you are using the csh or tcsh shell; in other shells, the redirections may be slightly different. The "<" redirects stdin (namely from file driver.m) into Matlab. For the background run not to hang, there must not be any screen output, so the ">&" redirects both stdout and stderr to the file driver.log; this file must not exist initially. Again, the redirection commands may be different in other shells and slight variations are possible (such as overwriting an existing log file).


How to Get Help from Matlab

There are several ways to get help from Matlab, and those are moreover accessible by different routes. I can only mention some of them here. For more options, either just play with Matlab or read the documenation, as suggested in the following section.

Help Available Inside the Command Window

The command window is the one with Matlab's ">>" prompt. Two Matlab commands can give you help inside this window (without starting any other windows, etc.), which might be important if you use Matlab remotely. Also, the help accessible in this way would work for functions and scripts written by you.

The command help functionname displays the help on the function with name functionname; this functions must be in the current directory or be found on the search path (try which functionname). Technically, this displays the comments at the beginning of the m-file with name functionname.m up to the first blank line or the first line of code.

If you do not know the name of the function on which you wish to see help, you can try the lookfor keyword command, which searches for a keyword in m-files on the search path; more precisely, it only searches the very first line of the comments in those m-file (technically called the H1 line by Matlab).

Full Graphical Help

If you use Matlab on your local machine, the HelpBrowser is available to access the complete documentation in many different ways, including by topic from the table-of-contents of the manuals, by name of function, or by (full-text) keyword search. There are many different ways to start this HelpBrowser, including several under the Help menue of the desktop or by clicking the question mark "?" near the top of the desktop. Or from the prompt ">>" in the command window, just say helpbrowser. You could also say helpdesk, helpwin, or doc, which might differ from each other by the page displayed in the HelpBrowser upon opening. Try out what seems most useful to you. I point out that Matlab might remember which page you looked at last in your previous session, so it is useless for me to predict exactly what will happen under various circumstances.

Besides starting the HelpBrowser as such (and then using its features to find what you want), you can start it up with the help on a particular function with name functionname by saying doc functionname; I have found that one sometimes has to issue this command twice to get the desired effect, though. If the HelpBrowser is not open yet, it is started up, or if it is already open, the page displayed is changed. You should see the help on the function in the main window of the HelpBrowser now. This is similar and in some cases identical to the one obtained by saying help functionname, but has often more information and additional examples; particularly, for graphics commands, you will find full examples displayed here, which would not be available by using help in the command window alone. You may want to compare the information available by saying help plot and doc plot.

As a general caution, you may have to wait for a moment for the HelpBrowser to come up. I suggest to resize the window to make it wide enough such that you can fit a full page in the right-hand part of the window, while still being able to read the titles of sections in the left-hand part.


How to Get Started with Matlab

The best way to get started with Matlab is to read Matlab's own documentation in the HelpBrowser. I am now assuming that your have started Matlab interactively and with the Java Virtual Machine (JVM) enabled. If it is not already present, start up the HelpBrowser by saying helpbrowser at the prompt of the command window.

The left-hand side of the window, the HelpNavigator, should show a table-of-contents with items such as "Begin Here", "Release Notes", "Installation", "MATLAB", and more. If you do not see these, make sure that the "Contents" tab is selected in the HelpNavigator. If you are missing the entire HelpNavigator, use the pull-down menu under "View" and make sure that "HelpNavigator" is selected there.

My recommendation for learning about Matlab and how to use it is to study the Getting Started guide, which is the first item under "MATLAB"; if not already visible, expand the table-of-contents of "MATLAB" by clicking on its plus "+" sign. You can see the table-of-contents of the Getting Started guide by clicking its plus sign. The first two sections "Introduction" and "Matrices and Arrays" explain the philosophy of Matlab and walk you through the most basic commands; you should enter them in the command window yourself The sections "Graphics" and "Programming" explain the use of graphics commands and how to program m-files in Matlab, respectively. Finally, the section "Desktop Tools and Development Environment" explains in details the features of the desktop environment.


Information for System Administrators

The following documents detail how a user or a system administrator---who is not assumed to know mathematics or the software package---could test whether an installation of Matlab or FEMLAB works properly.
Copyright © 1997-2005 by Matthias K. Gobbert. All Rights Reserved.
This page version 4.0, May 2005. Updated January 2016 to correct link to CIRC page on top.