Geoscience Reference
In-Depth Information
MATLAB also has cell arrays as an alternative to structure arrays. Both
classes or data types are very similar and are containers of dif erent types
and sizes of data. h e most important dif erence between the two is that the
containers of a structure array are named i elds , whereas a cell array uses
numerically-indexed cells . Structure arrays are ot en used in applications
where the organization of the data is particularly important. Cell arrays
are ot en used when processing large data sets in count-controlled loops
(Section 2.7).
As an example of cell arrays we use the same data collection as in structure
arrays, with the layers of the structure array as the cells in the cell array. h e
cell array is created by enclosing the location name Plougasnou , the date,
the image I and the 10-by-10 array of uniformly-distributed pseudorandom
numbers in curly brackets.
C = {'Plougasnou' date I rand(10,10)}
Typing
C
lists the contents of the cell array
C =
Columns 1 through 2
'Plougasnou' '27-Jun-2014'
Columns 3 through 4
[100x100x3 uint8] [10x10 double]
which contains the location name and date. h e image and the array of
random numbers are too large to be displayed in the Command Window,
but the dimensions and class of the data are displayed instead. We access a
particular cell in C , e.g., the cell 2, by typing
C{2}
which yields
ans =
27-Jun-2014
We can also access the other cells of the cell array in a similar manner.
2.6 Data Storage and Handling
h is section deals with how to store, import, and export data with MATLAB.
Many of the data formats typically used in earth sciences have to be converted
Search WWH ::




Custom Search