Matlab_11a

More Realistic Data

Real data is not just numeric and if you have a number of subjects, or sampling points, there is a good possibility that you will need more than one observation from each. The most general way to handle all possibilities is to put the results in a structure. Here are some structure data you can cut and paste:

position(1)=struct('name', 'Digford', 'grid', [010 020], 'temp', [68, 80, 72], 'rainfall', [0.2, 0.4, 0.0]);

position(2)=struct('name', 'Lagton', 'grid', [013 015], 'temp', [64, 83, 70], 'rainfall', [0.4, 0.2, 0.2]);

position(3)=struct('name', 'Beerness', 'grid', [017 022], 'temp', [81, 42, 32], 'rainfall', [0.0, 0.0, 0.2]);

and here is a script (or function if you want to write it as a function) that uses this data:

for ii = 1:length(position)

subplot(2,3,ii);

bar(position(ii).temp)

title(position(ii).name)

ylim([0 100]);

subplot(2,3,ii+3);

bar(position(ii).rainfall,'r')

ylim([0 0.5]);

end

Again, the point here is for you to understand how this works and to make changes to see if you can make it work better. Like this:

data = zeros(3,2);

for jj = 1:3

for ii = 1:length(position)

data(ii,1) = position(ii).temp(jj);

data(ii,2) = position(ii).rainfall(jj)*100;

end

subplot(1,3,jj);

bar(data)

legend({'Temp', 'Rainfall * 100'}, 'Location', 'SouthOutside');

title(['Day ' num2str(jj)]);

end