Lesson 4: Statements, expressions and variables; saving a session

MATLAB is an expression language; the expressions you type are interpreted and evaluated. MATLAB's statements are usually of the form:
variable = expression, or simply
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 on 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 seperated by commas or semicolons.

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

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

The command whos will list the variables currently in the workspace and their size. 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 2.2204e-16 on our machine. 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].

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 binary file named matlab.mat. When one later reenters MATLAB, the command load will restore the workspace to its former state.