|
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 each computer lab's section indicating MATLAB's version and the semester which this document was written and last updated for. In response to feedback, this page maybe updated 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 directly to this page, I suggest to link to the CIRC home page.
If you are interested in a class on the subject, consider our Math 426, which is a basic but thorough introduction. The workshops last for one hour and are held during Free Hour (12 noon - 01 pm) in ENGR 122, an instructional computer lab in the Engineering Building at UMBC.
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.
For the official answer, check out http://www.mathworks.com, the webpage of the MathWorks, Inc., maker of MATLAB.
UMBC maintains campus licences for MATLAB (and its toolboxes) under the Linux and Windows 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.
There are numerous DoIT computer lablocations throughout the campus.
Under Windows, start MATLAB in the usual way from the Start menu, by expanding the menu on Programs, MATLAB, then R2009b and then clicking on MATLAB R2009b. 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:\Users\username\Documents\MATLAB 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 us 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".
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 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.
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 is most easily performed under Linux on the remote machine.
On your Linux terminal, type "ssh -p 22 username@gl.umbc.edu -X". The -X command is necessary in order to use graphics. Once you are connected to the UMBC server, simply type "matlab" at the command prompt.
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. 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 -nosplash.
Under a Windows machine, X Windows programs can be used for remote access. For a description on running X Windows programs remotely, see that section under the Tips and Tricks portion of the High Performance Computing Facility (HPCF) webpage. If one does not wish to use graphics, other options can be used to remotely connect such as Putty. The previous item Running MATLAB Remotely (Under Linux) discusses how one can disable graphics.
This computer lab is available to current Math and Statistics graduate students. These computers use a Linux operating system
At the command prompt of the terminal, simply type "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.
On your Linux terminal, type "ssh -p 50022 username@pc26.math.umbc.edu -X". The -X command is necessary in order to use graphics. Once you are connected to the Math server, simply type "matlab" at the command prompt. For a discussion on how to disable MATLAB's desktop and graphics in your terminal, see the section under DoIT Computer Lab Running MATLAB Remotely (Under Linux).
Under a Windows machine, X Windows programs can be used for remote access. For a description on running X Windows programs remotely, see that section under the Tips and Tricks portion of the High Performance Computing Facility (HPCF) webpage. If one does not wish to use graphics, other options can be used to remotely connect such as Putty.
The tara cluster is accessible to individuals with an account through HPCF. Connecting to tara is done remotely.
On your Linux terminal, type "ssh -p 22 username@tara.rs.umbc.edu -X". The -X command is necessary in order to use graphics. Once you are connected to the server, simply type "matlab" at the command prompt. For a discussion on how to disable MATLAB's desktop and graphics in your terminal, see the section under DoIT Computer Lab Running MATLAB Remotely (Under Linux).
Under a Windows machine, X Windows programs can be used for remote access. For a description on running X Windows programs remotely, see that section under the Tips and Tricks portion of the High Performance Computing Facility (HPCF) webpage. If one does not wish to use graphics, other options can be used to remotely connect such as Putty.
A detailed description along with examples of how to run MATLAB on tara is provided on the HPCF webpage.
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.
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"; these 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).
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 menu of the desktop or by clicking the question mark "?" near the top of the desktop. Or from the prompt ">>" in the command window, just type 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 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.
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 graphics 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.