Next: Matrix building functions Up: No Title Previous: Matrix operationsarray

Statements, expressions, and variables; saving a session

MATLAB is an expression language; the expressions you type are interpreted and evaluated. MATLAB statements are usually of the form


variable = expression,
or simply

expression

Expressions are usually composed from operators, functions, and variable names. Evaluation of the expression produces a matrix, which is then displayed on the screen and assigned to the variable for future use. If the variable name and = sign are omitted, a variable ans (for answer) is automatically created to which the result is assigned.

A statement is normally terminated with the carriage return. However, a statement can be continued to the next line with three or more periods followed by a carriage return. On the other hand, several statements can be placed on a single line if separated by commas or semicolons.

If the last character of a statement is a semicolon, the printing is suppressed, but the assignment is carried out. This is essential in suppressing unwanted printing of intermediate results.

MATLAB is case-sensitive in the names of commands, functions, and variables. For example, solveUT is not the same as solveut.

The command who will list the variables currently in the workspace. A variable can be cleared from the workspace with the command clear variablename. The command clear alone will clear all nonpermanent variables.

The permanent variable eps (epsilon) gives the machine precision-about on most machines. It is useful in determining tolerences for convergence of iterative processes.

A runaway display or computation can be stopped on most machines without leaving MATLAB with CTRL-C (CTRL-BREAK on a PC).

Saving a session. When one logs out or exits MATLAB all variables are lost. However, invoking the command save before exiting causes all variables to be written to a non-human-readable diskfile named matlab.mat. When one later reenters MATLAB, the command load will restore the workspace to its former state.



Next: Matrix building functions Up: No Title Previous: Matrix operationsarray


ladi@
Wed Mar 13 19:15:55 MET 1996