|
Using MatlabIntroMatlab is an interactive package for numerical analysis, matrix computation, control system design and linear system analysis and design. In addition to all that fancy stuff, it has a wide array of features that are useful for the core math classes like graphing, differentiating, and solving linear systems and DE's. Getting StartedWe have two different licenses. One for classroom use (this includes doing homework) and one for research. Information about the differences between the two can be found here. You should use the classroom license when you are doing homework. The research license must be used for all non-classroom (and non-homework) use. Yes, this is a bit silly, but it's part of our contract with the makers of Matlab. On the Macintosh computers in the labs, Matlab is installed in /Network/Applications/MATLAB. Go to this folder in the Finder and open "Start MATLAB". It will launch X11 for you and start up Matlab. Note that as of version 7.0.4, Matlab runs under the X Window System, rather than Mac OS X's native windowing environment. While the makers have Matlab have tried to make it look somewhat like a normal Mac OS X application, it's quite obvious that it is not. For example, it has menubars in each window and many things don't work the same way as in other programs. If you want to ssh in from your dorm room and use matlab, you can use the copies installed on our Linux servers (knuth and wilkes). These are called "matlab-classroom" and "matlab-research" .. be sure to run the correct one. (If you forget and you try to run "matlab" you'll get a message reminding you of the names of the two versions.) If you have X11 on your computer and you have used SSH's option for tunnelling X11, then you will be able to see graphs and such. Otherwise, it will be text only. In the Matlab window you will be presented with an introductory message and a ">>" prompt. Pretty decent online help can be obtained at this point by typing "helpwin" or "help" (helpwin brings up an interactive window while help just uses the command line). You can also type "demo" to access demos on some common functions and the various Toolboxes we have installed. Demos of special interest to those at here at Mudd include most of the items in the Matrices submenu, as well as the 2-D and 3-D plotting examples in the Visualization submenu. Defining VariablesIn Matlab there are three basic types of variables: scalars, vectors, and matrices. Varables are definited by typing the name of the variable followed by an equal sign and the value of the variable. Vectors and matrices are denoted by enclosing the values in square brackets and rows within a matrix are separated by semicolons. For example:
A = 1 let A = 1
B = [1 2 3] let B = the vector [1 2 3]
1 2 3
c = [1 2 3; 4 5 6; 7 8 9] let c = 4 5 6
7 8 9
Keep in mind that variable names are case sensitive, so if it looks like
something isn't getting assigned correctly check to make sure you got your
cases right.
Frequently Used CommandsGraphing FunctionsGraphing functions in 2 dimensions is accomplished using the plot command. To graph functions in 3 dimension use plot3 or one of its variants as enumerated below.
Matrix OperationsThe following matrix operations are available in Matlab:
You should be familiar with most of these operations if you have taken a course in linear algebra, but a couple of them (namely left and right division) bear some explanation. A\b returns the matrix x which is a solution to Ax = b. Similarily, b/A returns the matrix x which is a solution to xA = b. These two operators let you solve systems of equations easily assuming you know your A and b. In addition to these operations Matlab also supports some simple functions on matrices. For example det(A) will compute the determinant of A while inv(A) will calculate its inverse. For an exhaustive list of all the available matrix function type help matfun. Miscellaneous Commands
Matlab Toolkits AvailableIn addition to the standard Matlab libraries we have available several special purpose toolkits.
Copyright (c) HMC Computer Science Department.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the no Invariant Sections, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the license is included in the section entitled ``GNU Free Documentation License.''
HMC Computer Science Department Contact Information |