Graphics Programs Reference
In-Depth Information
>> meteo(2).Pressure(2:3) = [NaN NaN];
>> meteo(2).Pressure
ans =
1015
NaN
NaN
Suppose now that we have discovered that all our pressure readings were
wrong; we need to delete the pressure field altogether from the structure:
>> meteo = rmfield(meteo,'Pressure')
meteo =
1x2 struct array with fields:
Site
Time
Temperature
Now we want to add humidity measurements at the two sites. Suppose
Adelaide's humidity was 69% and Sydney's was 86%, 80%, and 76% at
the three different times:
[meteo.humidity] = deal(69,[86 80 76]);
>> meteo(1)
ans =
Time: 2.3000
Temperature: 24
humidity: 69
>> meteo(2)
ans =
Site: 'Sydney'
Time: [4 8 11]
Temperature: [19 16.5000 15.3000]
humidity: [86 80 76]
(The deal command copies a list of inputs to a list of outputs.)
To do operations on field elements, just treat them as any other
matlab array:
>> meteo(2).Temperature
ans =
19.0000 16.5000 15.3000
>> mean(meteo(2).Temperature)
ans =
16.9333
The temperature measurements at both sites in the structure are
accessed by typing:
Search WWH ::

Custom Search