Graphics Programs Reference
In-Depth Information
Set
Getting Started with MATLAB
will download a portable docu-
ment format (PDF) version of the
Getting Started with MATLAB
man-
ual.
You can learn how to use any matlab command by typing
help
followed by the name of the command, for example,
help sin
.
You can also use the
lookfor
command, which searches the help
entries for all matlab commands for a particular word. For example, if
you want to know which matlab functions to use for spectral analysis,
you could type
lookfor spectrum
. matlab responds with the names
of the commands that have the searched word in the first line of the help
entry. You can search the entire help entry for all matlab commands
by typing
lookfor -all
keyword
.
→
1.2 First Steps
To get matlab to work out 1+1, type the following at the prompt:
1+1
matlab responds with
ans =
2
The answer to the typed command is given the name
ans
. In fact
ans
is now a variable that you can use again. For example you can type
ans*ans
to check that 2
×
2=4:
ans*ans
ans =
4
matlab has updated the value of
ans
to be 4.
The spacing of operators in formulas does not matter. The following
formulas both give the same answer:
1+3 * 2-1 / 2*4
1+3*2-1/2*4
The order of operations is made clearer to readers of your matlab code
if you type carefully:
1 + 3*2 - (1/2)*4