MS&E 251 Stochastic Decision Models
Winter 2005
M. O’Sullivan & A. F. Veinott, Jr.
Rev 1:35 am, 1/7/05
1
MATLAB OVERVIEW
===============
WHAT IS MATLAB?
MATLAB is a software package available via your Leland account. You can also buy a
student or professional version for your PC or MAC. MATLAB is designed for the ma-
nipulation and visualization of matrices, and analysis of large amounts of data.
HOW DO I START MATLAB?
To use MATLAB, first log into your Leland account using either tree.stanford.edu,
firebird.stanford.edu or raptor.stanford.edu. Not only do they run MATLAB much fas-
ter than cardinal, but if you log on to cardinal.stanford.edu you may be knocked off
of MATLAB. Once you have logged on to your Leland account and your msande251 direc-
tory, type "matlab", e.g.,
firebird2:~/msande251> matlab
MATLAB responds with:
< M A T L A B >
Copyright 1984-
The MathWorks, Inc.
2004
Version 7.0.0.19901 (R14)
May 06, 2004
To get started, type one of these: helpwin, helpdesk, or demo
For product information, visit www.mathworks.com.
>>
The above >> is the MATLAB prompt. A MATLAB command is executed by typing it at this
prompt and then striking the ENTER key. What follows is the MATLAB reply. In the se-
quel the lines with >> are command lines and the rest are MATLAB replies.
HOW DO I QUIT?
Type "quit" from the command line, e.g.,
>> quit
firebird2:~/msande251>
NAVIGATING MATLAB
Typing "help general" will give information on general purpose commands useful for
navigating MATLAB. UNIX shell commands may also be executed by putting a ! before
the command. For example, to edit a file "words.txt" using EMACS while running MAT-
LAB type "!emacs words.txt".
MATRICES
MATLAB was originally written as a matrix manipulation program, and therefore tends
to try to deal with everything as a matrix. Although it is possible to input equa-
tions, assign variables, and use a lot of mathematical functions, to make efficient
use of MATLAB, it is necessary to use matrices. To enter a small matrix, type