next up previous contents
Next: Some MATLAB commands Up: Introduction Previous: Math Emporium Use   Contents


Generally MATLAB syntax is pretty conventional (i.e., similar to current programming languages). If you are used to Mathematica, one difference that you will notice is that the arguments of functions are enclosed in parentheses (e.g., $\sin (x)$) rather than with square brackets. In MATLAB, square brackets are used to specify vectors or matrices. For instance [1,0,0;0,1,0;0,0,1] would specify the usual 3x3 identity matrix. Either commas or spaces can be used to separate the elements in a row; semicolons separate the rows themselves. Variables always have values: numerical (integer, real or complex), matrix, or string. String values are indicated by enclosing them in single quotes, as you will see below.

Our primary use of string variables will be to specify the right hand side (RHS) of a differential equation of the form $x'=f(t,x)$. For example if we are going to work with the differential equation $x'= 2tx$ then we would make the following assignment to a string variable named ftx:

Note that * is used to indicate multiplication. Any valid MATLAB expression can make up the string, as long as the only two variables used are t and x (remember we are entering an equation of the form $x'=f(t,x)$). For instance 'exp(t$\wedge$3 - 1)/sqrt(log(x$\wedge$2+1))' is also an acceptable string variable.

MATLAB commands are entered at the prompt >>. Virtually all commands have an associated M-file given by command_name.m. For example, quit is the command to end a MATLAB session and close the software. Typing quit at the prompt >> invokes the M-file quit.m. Similarly, creating a M-file with MATLAB commands and/or variable assignments also allows you to call the M-file using its name, minus the .m extension. The file init.m is such a file as is sol1.m. If you are in the directory/folder containing init.m, typing init will invoke the file and those commands/assignments it contains. The same holds for sol1.m and sol1. All of these files are simple ASCII text files. (Remember though that you must copy-and-paste init.m at the Emporium.)

Information on almost any command/file can be obtained by typing help command at the prompt. For example, help quit brings up information on the command quit, which is also the information on the file quit.m.

For more about general MATLAB use there are several books available. One of these is Engineer's Toolkit, required for most VT engineering majors. Another is the new tutorial compiled by the Mathematics department. MATLAB itself has a built-in tutorial (type the command intro).

For the begining of this class, you will basically only need to know these simple facts. However some other information may make you more comfortable.

next up previous contents
Next: Some MATLAB commands Up: Introduction Previous: Math Emporium Use   Contents
Michael Renardy