UMBC logo
  Center for Interdisciplinary Research and Consulting


How to Get Started with MATLAB at UMBC

Purpose of this Document

This document explains 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.

If you are interested in how to use MATLAB, come to free software workshops offered by CIRC. They are held during Fall and Spring semesters on Wednesdays during Free Hour (12noon-01pm) in room ENGR 122, an instructional computer lab in the Engineering Building at UMBC. The workshops on MATLAB form a sequence that covers topics from a basic introduction to efficient simulations.

For a more thorough introduction with guided homework projects, consider the official 2-credit class MATH 426 Introduction to Math Software Packages: MATLAB that the Department of Mathematics and Statistics offers in Summer and Winter semesters.

What is MATLAB?

MATLAB's name originates from Matrix Laboratory, since it 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.

For the official description of MATLAB, check out http://www.mathworks.com, the webpage of the MathWorks, Inc., maker of MATLAB.

Where Can I Use MATLAB at UMBC?

UMBC maintains a campus licences for MATLAB and many of its toolboxes. 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.

DoIT Computer Labs - Current Version: 8.1.0.604 (R2013a) - As of August 2013

Starting MATLAB in Windows

Under Windows 7 or 8, click on the Windows Start Orb to open the Start Menu, type "matlab" to search for the program, then click on the version you want to run. MATLAB might remember whether you had other windows open at the end of your previous session, so the Help browser (which might even open with the page you last visited) and other windows may open again.

At present (8/2013), in the UMBC computer labs, MATLAB starts up in a folder similar to \\profile.ad.umbc.edu\Userfiles$\username\My Documents\MATLAB. This directory is visible in the "Current Folder Toolbar" above the other desktop windows and below the "Toolstrip".

As an example of how to create a directory structure for your current project, here are instructions that a student in Math 426 can use to to organize her files for that course. First, create a folder for this class by entering "mkdir Math426" on the MATLAB command line (the window with the >> prompt), and then change into it by entering "cd Math426". Next, create a directory for each homework by entering "mkdir Homework1" and change to it by entering "cd Homework1". Check what the Current Folder Toolbar says or enter "pwd" (print working directory) at the MATLAB command line.

Starting MATLAB in Linux

Under Linux, you need to get a command window (shell) first. Then, enter "matlab" at the command window prompt (and press return). To get more information on command line options, enter "matlab -h" at the Linux command prompt, which gives information about possible command line arguments, but does not start MATLAB. MATLAB might remember whether you had other windows open at the end of your previous session, so the Help browser and other windows may open again.

Under Linux, it makes more sense to change directory first at the Linux command line and before starting MATLAB, using the 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 from 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, or your local machine may not have sufficient memory for your task. In these cases, running MATLAB remotely may be worthwhile.

On your Linux terminal, enter "ssh -X username@linux3.gl.umbc.edu", where username is your UMBC username. The -X argument enables graphics. Once you are connected to the UMBC server, enter "matlab" at the Linux command prompt. Note: the MATLAB version on linux3.gl.umbc.edu, as of August 2013, is 2012a (7.14.0.739) 64-bit (glnxa64), which differs from that in the computer labs. It seems that MATLAB is not available on the linux2 and linux1 servers.

Sometimes the performance of remote graphics is frustratingly slow, in which case you may want to start MATLAB (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by using "matlab -nodesktop -nodisplay". To get more information on command line options, enter "matlab -h".

Running MATLAB Remotely from Windows

Under the Microsoft Windows operating systems, Linux X Windows programs can be used for remote access. For a description on running X Windows programs remotely, see that section under the General Productivity portion of the High Performance Computing Facility (HPCF) webpage. There, you will find instructions which include installing PuTTY (for the remote SSH connection) and Xming (for remote graphics). If you do not wish to use graphics, perhaps because the connection is slow, you may want to start MATLAB (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by using "matlab -nodesktop -nodisplay". To get more information on command line options, enter "matlab -h".

Mathematics & Statistics Computer Lab - Current Version: MATLAB R2012a (7.14.0.739) 32-bit - Updated: Fall 2012

This computer lab is available to current Math and Statistics graduate students. These computers use a Linux operating system.

Starting MATLAB

At the command prompt of the terminal, enter "matlab". One can create additional terminals by right clicking on the desktop and selecting xterm. Files which are saved will be saved under your personal account space and not on the desktop.

High Performance Computing Facility (HPCF) - Current Version: R2012b (8.0.0.783) 64-bit (glnxa64) - As of August 2013

The tara cluster is accessible to individuals with an account through HPCF. Connecting to tara is done remotely.

Running MATLAB Remotely from 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, or your local machine may not have sufficient memory for your task. In these cases, running MATLAB remotely may be worthwhile.

On your Linux terminal, enter "ssh -X username@tara.rs.umbc.edu", where username is your UMBC username. The -X argument enables graphics. Once you are connected to tara, enter "matlab" at the Linux command prompt.

Sometimes the performance of remote graphics is frustratingly slow, in which case you may want to start MATLAB (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by using "matlab -nodesktop -nodisplay". To get more information on command line options, enter "matlab -h".

Running MATLAB Remotely from Windows

Under the Microsoft Windows operating systems, Linux X Windows programs can be used for remote access. For a description on running X Windows programs remotely, see that section under the General Productivity portion of the High Performance Computing Facility (HPCF) webpage. There, you will find instructions which include installing PuTTY (for the remote SSH connection) and Xming (for remote graphics). If you do not wish to use graphics, perhaps because the connection is slow, you may want to start MATLAB (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by using "matlab -nodesktop -nodisplay". To get more information on command line options, enter "matlab -h".

Running MATLAB programs on tara in batch mode

A detailed description along with examples of how to run MATLAB on tara is provided on the HPCF webpage. The cluster tara is meant for batch processing, so this is the preferred mode of running MATLAB for production runs.

How to Get Help from MATLAB

There are several ways to get help from MATLAB. MATLAB's internal documentation, described in the next section, is very useful. Additionally, searching the internet, e.g., via google.com, has recently increasingly proven to be a very useful way to debug problems. While searching the internet, you will discover several online forums for posting and answering questions about MATLAB.

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 called "functionname". This syntax works for any function that is be in the current directory or on the search path. Use "which functionname" to find out exactly which function on the search path is being called. The "help" command works by displaying 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, you can search for it using the "lookfor keyword" command, which searches for "keyword" in the first line following the function declaration (called the H1 line) of all m-files on the search path. Use "help lookfor" for an explanation of how to expand this search to the entire first comment block of each m-file.

Full Graphical Help

If you use MATLAB on your local machine, the Help browser 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 Help browser, including several under the Help menu of the desktop or by clicking the question mark "?" near the top of the desktop. Or from the prompt ">>" in the command window enter "helpbrowser". You could also say helpdesk, helpwin, or doc, which might differ from each other by the page displayed in the Help browser upon opening. Try out what seems most useful to you. Note that MATLAB might remember which page you looked at last in your previous session, so it is useless to predict exactly what will happen under various circumstances.

Besides starting the Help browser and then using its features to find what you want, you can directly open the Help broswer for a particular function functionname by entering "doc functionname". It is sometimes necessary to issue this command twice to get the desired effect, though. If the Help browser is not open yet, it is started up, or if it is already open, the page displayed is changed. The help content via entering "doc functionname" is similar, and in some cases identical, to that obtained via entering "help functionname", but the former command often has more information and additional examples; and, especially for graphics commands, you will find full examples which would not be available by using "help" in the command window alone. However, sometimes the more compact information inside the command window has its advantages. Try comparing the information available from "help plot" with "doc plot".

How to Get Started with MATLAB (2013a)

The best way to get started is to read MATLAB's internal documentation via the Help browser. From within MATLAB, you can open the Help browser by typing "doc" at the prompt of the command window.

Help opens with tabs for Installation and Release Notes, and with available help for the main MATLAB package, as well as all of the installed Toolboxes. Click on MATLAB, or the Toolbox of interest, then

An excellent way to learn about MATLAB's features and how to use them is to study the "Getting Started with MATLAB" guide, which is the first item under "MATLAB"; if not already visible, expand the "Contents" tab on the left of the screen by clicking on the little icon above the word "Contents".

The "Getting Started with MATLAB" and "Language Fundamentals" sections explain the philosophy of MATLAB (including the features of the desktop environment) and walk you through the most basic commands. You should try out commands in the command window while reading the Getting Started guide. The "Graphics" section explains the use of graphics commands, including MATLAB's Handle Graphics objects. The "Programming Scripts and Functions" section explains how to program using MATLAB's m-files.

In addition to this help inside of MATLAB, MathWorks also makes the documentation available online. Try an internet search like "matlab handle graphics", and one of the first results will be MathWorks' online documentation.