Graphics Programs Reference
In-Depth Information
9.1 MATLAB Format
To save all the variables in the workspace onto disk use the save com-
mand. Typing save keepfile will save the workspace variables to a
disk file called keepfile.mat , a binary file whose format is described in
the matlab documentation. This data can be loaded into matlab by
typing load keepfile .
To save or load only certain variables, specify them after the filename.
For example, load keepfile x will load only the variable x from the
saved file. The wild-card character * can be used to save or load variables
according to a pattern. For example, load keepfile *_test loads only
the variables that end with _test .
When the filename or the variable names are stored in strings, you
can use the functional forms of these commands, for example:
is the same as save('keepfile')
save keepfile
save keepfile x
load keepfile
A = 'keepfile'
Exercise 3 The file clown.mat contains an image of a clown.
What colour is his hair? (Answer on page 183.)
9.2 ASCII Format
A file containing a list or table of numbers in ASCII format can be loaded
into matlab. The variable containing the data is given the same name
as the file name without the extension. For example, if a file nums.dat
contained ASCII data, load nums.dat would load the data into a vari-
able called nums . If the ASCII file contained a table of numbers, the
variable would be a matrix the same size as the table.
Other functions are available to read various forms of delimiter-
separated text files:
csvread Read a comma separated value file
csvwrite Write a comma separated value file
dlmread Read ASCII delimited file
dlmwrite Write ASCII delimited file
9.3 Other Formats
matlab's low-level input/output routines can be used to access more
unusual data formats. They are listed here for reference:
Search WWH ::

Custom Search