# 元胞数组与结构体数组

### 结构体数组

patient(1).name = 'John Doe';
patient(1).billing = 127.00;
patient(1).test = [79, 75, 73; 180, 178, 177.5; 220, 210, 205];

patient(2).name = 'Ann Lane';
patient(2).billing = 28.50;
patient(2).test = [68, 70, 68; 118, 118, 119; 172, 170, 169];

patient
patient=1×2 struct array with fields:
name
billing
test

numPatients = numel(patient);
for p = 1:numPatients
figure
bar(patient(p).test)
title(patient(p).name)
xlabel('Test')
ylabel('Result')
end

### 元胞数组

temperature(1,:) = {'2009-12-31', [45, 49, 0]};
temperature(2,:) = {'2010-04-03', [54, 68, 21]};
temperature(3,:) = {'2010-06-20', [72, 85, 53]};
temperature(4,:) = {'2010-09-15', [63, 81, 56]};
temperature(5,:) = {'2010-12-09', [38, 54, 18]};

temperature
temperature=5×2 cell array
{'2009-12-31'}    {[ 45 49 0]}
{'2010-04-03'}    {[54 68 21]}
{'2010-06-20'}    {[72 85 53]}
{'2010-09-15'}    {[63 81 56]}
{'2010-12-09'}    {[38 54 18]}

allTemps = cell2mat(temperature(:,2));
dates = datetime(temperature(:,1));

plot(dates,allTemps)
title('Temperature Trends for Different Locations')
xlabel('Date')
ylabel('Degrees (Fahrenheit)')