>>
, a command can be typed. After having pushed the `return' key, the command is executed, and possibly the result appears on the screen. A command and its result looks like this:
>> a = 1 + 2 + 3 a = 6
The result of 1 + 2 + 3 is assigned to the variable a. You can now use this variable in succesive operations, such as:
>> b = 2*a + a/3 b = 14
In MATLAB, variables are introduced by assigning a value. Note, that the value can be numerical values, matrices (called arrays), or other types. You can use the variable, and later possibly assign a new value to the variable. It is not possible to perform calculations with variables that have not been assigned a value.
A command does not need to start with an assignment of the form variable =
. In such a case, the result is automatically assigned to the variable ans. You can then use ans further.
>> 4*a + 1 ans = 25 >> ans*ans ans = 625
If you now want to know what the value of a is, the following command suffices:
>> a a = 6
Normally, MATLAB displays the output below the command. The output is suppressed by ending the command with a semicolon. After having entered the command
>> s = 1 + 2;
The value 3 has been assigned to the variable s. If you want to know the value of this variable, you can either look in the " Workspace" window on the top left of your MATLAB window, or request the value of s as follows
>> s s = 3
If a command is longer than one line, you can end the line with three dots, and then press the `return' key. You can then continue on the following line. After completing the command, the screen looks as follows:
>> s = 1 + 2 + ... 3 + 4 s = 10
Mathematical expressions
You cannot enter mathematical expressions literally. The Tables 1.11.2 make clear how mathematical expressions can be entered. The variables in these tables are to be interpreted as numbers.

Remark:
The order of operations in MATLAB is the standard order: first raising to a power, then multiplication and division, and after that addition and subtraction. To deviate from this sequence, parentheses `(' and `)' need to be used to define the order of calculations, e.g.
1/(exp(3)+1)
.
Interruption
A (long) MATLAB calculation can be interrupted with `ctrlc'. After this, a new prompt appears and new commands can be entered. This interruption is especially useful when a programmed loop is running that is corrupt.
Incomplete commands
If a command is incomplete or invalid and you press the `return' key, there are two possibilities:
Variables
The name of a variable in MATLAB has to start with a letter. After that, the name can consist of an arbitrary number of letters, numbers or symbols like '_' and ''. MATLAB does distinguish between upper and lower case letters.
MATLAB uses some special variables, shown in Table 1.3.

Warning: in principle, it is possible to assign a value to the internal MATLAB variables presented in Table 1.3.
This can influence your calculations. Therefore, it is wise never to assign a value to an internal MATLAB variable.
Commands like >>pi=10
should be avoided at all times! If by accident you have given a different value to an internal
MATLAB variable, you can remove this value by using clear
or the workspace browser.
On the top right of the default MATLAB window, you will find the "Workspace" window where
all variables in use are listed. The browser also indicates to which class the variables belong. If necessary,
you can remove variables by using the browser. The special variables above will not be listed
Some other important commands for the management of variables are given in Table 1.4.
