Getting Matlab to run
On your own laptop...you're on your own...
On Athena type (without the athena% prompt)
athena% add matlab
It takes about 30-60 secs to start up... and you'll get a screen
Alternatively, you can type
athena% add matlab
The most awful truth about computers is that they are all dumb. Everything must be explicitly told. Spelling out the most minor and obvious detail. Otherwise, you will either get a syntax error (computer not understanding what you are saying) or a programming error (the computer understanding what you are saying but it is different from what you mean).
The Command Prompt
In the interactive terminal of Matlab you will see the command prompt (>>). This is Matlab's way of telling you that it is ready to receive instructions from you. To command Matlab, type your request and hit Enter. Matlab then evaluates your command and displays the output (if any).
To get help use the help, and lookfor commands. help should be used to find out information about a known command, e.g. help zeros.
If you do not get the command prompt for some reason, you may have typed a syntax error, or have put Matlab into an infinite loop. Don't panic! press Ctrl-C and you'll get the prompt back.
Matlab's most basic building blocks are expressions: 1, 1+1,4*3, 4^2, 5/6.
To transpose a matrix (or vector) use the apostrophe ('):
Try to solve these with a single Matlab command:
Asking Matlab to calculate things for us is great, but most of the times a calculation is only one step out of many and the result of a calculation need to be saved for the (very near) future. To do this we use 'variables', which are simply a way to name a bit of Matlab data. This is best explained by example:
puts the value 1 into a variable called a. typing
results back in the value 1.
We can also assign a calculation into a variable:
and now b will contain the answer, 2.
Variable names can (and should) be longer than one letter. A word or a couple of words strung together tends to work the best.
Referencing matrix elements
We can access the elements of a matrix in the following manner:
>> a=[1 4 3 5 6]
>> b=[1 2 ; 3 4]
Where the numbers in the parenthesis are (row, column).