Page 103 - Basics of MATLAB and Beyond
P. 103
We can capture this list by giving whos an output variable:
>> varlist = whos
varlist =
5x1 struct array with fields:
name
size
bytes
class
The average size of the variables is
>> mean([varlist.bytes])
ans =
140
A cell array of variable names can be generated by:
>> names = {varlist.name}
names =
’a’ ’acell’ ’meteo’ ’name’ ’vect’
Similar structures are generated by giving output arguments to what
and dir.
29 Multidimensional Arrays
Multidimensional matrices are natural extensions of the normal two-
dimensional matrices for cases where the data represent more than two
dimensions. Examples are
• Medical tomography, where three-dimensional volumetric data are
built up from a series of two-dimensional images;
• Temperature measurements taken at a three-dimensional grid in a
room;
• Temperature measurements taken at a three-dimensional grid in
a room and at a sequence of times, leading to a four-dimensional
data set;
• Red, green and blue components of a two-dimensional image, an
M × N × 3 matrix; and
• Acoustic measurements of sound spectra as a function of frequency,
direction of arrival, and time (sonar).
Let us get the hang of things by generating a 3 × 3 × 3 matrix:
c 2000 by CRC Press LLC