%LeafAnalysis - Math 151 
%first read in data from a file
%   load leafstat.dat
%then read in this file of commands for MATLAB
%
who,pause
%
% plot the data for first set of leaves as
% a scatterplot and histograms
%
plot(l,w,'+')
title('l versus w'),pause
hist(l)
title('l'),pause
hist(w)
title('w'),pause
%
% plot the data for the second set of leaves as
% a scatterplot and histograms
%
plot(l3,w3,'or')
title('l3 versus w3'),pause
hist(l3)
title('l3'),pause
hist(w3)
title('w3'),pause
%
% plot the data for both sets of leaves as
% a scatterplot 
%
plot(l,w,'+',l3,w3,'or')
title('length vs width'),pause
%
% compute the means for each leaf set and 
% then plot the data for both sets of leaves as
% a scatterplot showing the point of the means 
%
meanl=mean(l),meanw=mean(w),pause
meanl3=mean(l3),meanw3=mean(w3),pause
plot(l,w,'+',mean(l),mean(w),'or')
title('l versus w with mean'),pause
plot(l3,w3,'+',mean(l3),mean(w3),'or')
title('l3 versus w3 with mean'),pause
%
% compute the standard deviation for each leaf set  
%
stdl=std(l),stdw=std(w),pause
stdl3=std(l3),stdw3=std(w3),pause
plot(l,w,'+',l3,w3,'or')
title('length versus width'),pause
%
% compute the linear regression for each leaf set and 
% then plot the data for both sets of leaves as
% a scatterplot showing the linear regression line 
%
c=polyfit(l,w,1),pause
m=[min(l) max(l)]
x=polyval(c,m)
plot(l,w,'+',m,x)
title('l-w linear regression'),pause
c2=polyfit(l3,w3,1),pause
m2=[min(l3) max(l3)]
x2=polyval(c2,m2)
plot(l3,w3,'+',m2,x2)
title('l3-w3 linear regression'),pause
plot(l,w,'+',m,x,l3,w3,'og',m2,x2),pause

