Matmap Documentation
[Documentation home]
Matlab tips
Using the -nodesktop option
When starting matlab the desktop enviroment can be ignored and matlab
can be run directly from the command line. The advantage of running
from the command line is that on OSX platforms the keyboard interaction
is faster and there is no apparent delay between the text that appears
on the screen and what is being typed. On the SGI platforms the desktop
seems to enhance the instability of matlab and it tends to crash more
frequently using the desktop environment.
Use the following line to launch matlab without the desktop
> matlab -nodesktop
In case the splachscreen (the matlab logo window that is
launched when starting matlab) starts to be annoying use the -nosplash
option to suppress this option as well
> matlab -nodesktop -nosplash
Macintosh machines vs SGI
machines at
CVRTI
In case of using the GUI system, there is a clear preference for
using matlab on the macintosh machines. Currently the SGI version of
matlab is less stable with its interaction with the X11 windowing
system on the SGI machines than on the macintosh machines. On the SGIs,
using a lot of GUI elements has the tendency to stall matlab once in a
while. Furthermore, most G4 and G5 machines are faster than the SGI
machines and hence it does not make any sense to run the software from
the SGIs and port the display to macintosh machines.
The 'more problem'
On of the problems sometimes encountered when scripting a lot of
operations in an m-file, is that it generates a lot of text on the
screen and waits for you to read it.
This option is similar to the |more in most shells. In case it is
switched on use the following statement to switch it off:
>>more off
Getting help in matlab
In order to get help on any of the build-in functions in matlab type
the following
>>help functionname
where functionname is
the name of the function you want help on
Often you don't know the name of the function you are looking for, in
that case just type help and an overview of all help topics will be
rendered, then choose a topic and look for the function you want to
use, e.g.
>> help
this will give the general list
when you decide to look for a function that does some elementary
operation on a matrix, you may want to look in the elmat class, then
type
>> help elmat
Like all the functions in matlab, most of the functions in matmap will
have a short description of the functionality and how to use that
function. Use the help function to retrieve this help.
In the matmap system most functions (there are a few exceptions) start
with the directory in which they are located. For instance all I/O
functions start with io..... In order to quickly look for a function
you can do the following, type the first couple of letters of the
functions and then press tab. Matlab will now list all functions that
start with this combination of letters, e.g.
>> io<press tab>
Using Cell arrays in Matlab
A cell array is one of the less commonly used matlab features,
hence a
short overview of there is described here.
A cell array is a collection of matlab arrays: each cell contains a
matlab array.
In stead of using round brackets, which are used for numeric arrays, a
cell array uses curly brackets to access the contents of a field.
>> A{1} = rand(4);
this will enter a 4x4 random dense matrix at the first position of the
cell array
An empty cell array can be generated as well:
>> B = cell(2,3);
this will create an empty 2 by 3 cell array.
A matrix can now be assigned to each cell by specifying their indices:
>> B{1,2} = [1:10];
this will add a matrix at cell (1,2).
By default each cell array will be empty. An empty matrix is a special
matrix in matlab and contains
no data. A matrix can be declared empty as follows:
>> B{1,2} = [];
To test whether a cell is empty (i.e. contains an empty matrix)
>> isempty(B{1,2})
This will return a 1 if the matrix is empty
There are more functions dealing with cell arrays, but this should
summarise the basics.
Using Struct arrays in Matlab
A struct array is useful tool in matlab and is similar to the C
struct
command.
A structured matrix is a collection of sub-matrices, each identified by
a field name.
The easiest way to create a structured matrix is to create a field in
an empty matrix:
>> C.fieldname = rand(4);
This will create a matrix C with a field called 'fieldname', which
contains a random 4 by 4 matrix
To retrieve the contents of the field just specify the fieldname
>> C.fieldname
To add another field to C, just specify the second fieldname
>> C.secondfield = [1:10];
To remove a field you need to use the function rmfield
>> C =
rmfield(C,'secondfield')
this will remove the second field
Another useful function is 'isfield()' to test whether a field exists
>> isfield(C,'fieldname')
[Documentation home]