
Go backward to 2.4 Using MATLAB for Plotting
Go up to 2 Starting with MATLAB
Go forward to Some Examples
2.5 Other Miscellaneous MATLAB Commands
In this section, some other useful MATLAB commands are discussed.
For a full description, see the MATLAB help for
the function.
- sort: As the name suggests, sort sorts the
data in ascending order. -sort(-x) sorts the data in
x in descending order.
- diary: Typing
diary mine.txt at the MATLAB prompt creates a file
called mine.txt containing all the information printed in
the MATLAB command window from the time the command is entered.
To turn off this feature, type diary off. (This can be useful
when submitting assignments to show what was happened at the computer.)
- ones and zeros: These commands create vectors of ones and zeros of given size.
- eye: This command create an identity matrix of a given size,
usually called I.
- size: This command returns the number of rows and the number of columns
of a given matrix.
- ans: Issuing this command at the MATLAB prompt recalls the last
answer that wasn't assigned to another variable name.
- ...: If the command line won't fit on one line, end the line with three
dots. This tells MATLAB that the line that follows is a
continuation of the previous line. For example, a large vector
can be defined like this:
>> HPrices=[150000, 200000, 125000, 350000, 89000, 110000, ...
110000, 150000, 120000, 100900, 93500, 97000, ...
88000, 118500, 123300, 165000, 95000]';
When defining a long vector, it can be very useful
to use the line continuation facility by ending the lines with
the characters ....
Peter Dunn
