### Basics

To start the program type matlab at the Unix prompt, as follows:
```	% matlab
```
The system should respond (eventually) with:
```        Commands to get started: intro, demo, help help
>>
```
Our first command will make a record of the session, in a file named "session". [The ">>" is Matlab's prompt, you don't need to type it]. Enter:
```	>> diary session
```
Arithmetic uses some fairly standard notation. More than one command may be entered on a single line, if they are seperated by commas.
```	>> 2+3
>> 3*4, 4^2
```
Powers are performed before division and multiplication, which are done before subtraction and addition.
```	>> 2+3*4^2
```
The arrow keys allow "command-line editing," which cuts down on the amount of typing required, and allows easy error correction. Press the "up" arrow, and add "/2." What will this produce?
```	>> 2+3*4^2/2
```
Parentheses may be used to group terms, or to make them more readable.
```	>> (2 + 3*4^2)/2
```
The equality sign is used to assign values to variables.
```	>> x = 3
>> y = x^2
>> y/x
```
If no other name is given, an answer is saved in a variable named "ans."
```	>> z=2*ans, ans
```
Here z was defined in terms of ans. The result was called z, so ans was unchanged.

To get a list of your variables, use one of

```	>> who, whos
```
In Matlab, like C or Fortran, variables must have a value [which might be numerical, or a string of characters, for example]. All arithmetic is done to double precision [about 16 decimal digits], even though results are normally displayed in a shorter form.
```	>> a=sqrt(2)
>> format long, b=sqrt(2)
>> a-b
>> format short

```
To save the value of the variable "x" to a plain text file named "x.value" use
```	>> save x.value x -ascii
```
To save all variables in a file named mysession.mat, in reloadable format, use
```	>> save mysession
```
To restore the session, use
```	>> load mysession
```
To find out about this kind of thing, consult the help system. There's even an HTML version!
```	>> help
>> help general
>> doc
```
```	>> quit
```
Then, to see the saved files from your session, type
```	% more foo
% more x.value
```