cw199014_matlaboverview

cw199014_matlaboverview - MS&E 251 Stochastic Decision...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MS&E 251 Stochastic Decision Models 2 Winter 2005 M. O’Sullivan & A. Veinott, Jr. MATLAB OVERVIEW >> [1 2 3; 4 5 6] with rows separated by semicolons and MATLAB responds with ans = 1 2 3 4 5 6 This matrix can also be entered in its usual form with carriage returns replacing the semicolons. >> [1 2 3 4 5 6] ans = 1 2 3 4 5 6 When entering a matrix, elements are separated by a space, rows are separated by a semicolon and the matrix is enclosed in square brackets. SUPPRESSING OUTPUT After typing a MATLAB command, the output of that command is displayed. To execute a command and not display the output, follow the command with a semicolon. >> [1 2 3 4 5 6]; VARIABLES and WORKSPACE When you create a matrix, you can assign it a variable consisting of characters and numbers--the first a character, e.g., r2D2, x32, Y5, A, etc. To display the value of a variable, type its name. >> A = [1
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/03/2011 for the course MS&E 221 taught by Professor Ramesh during the Winter '11 term at Stanford.

Page1 / 17

cw199014_matlaboverview - MS&E 251 Stochastic Decision...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online