Wednesday, March 30, 2011

Matlab Plot - Simple example with labeled axes

Matlab Plot - Simple example with labeled axes and changing other options.
Figure example

%GraphScriptfinal
%use thickline and label y,x

%I. Start
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear

load 'matdata.mat'
% whos
%   A         60x1               480  double             
%   B         30x1               240  double             
%   C         20x1               160  double                  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Note we can force the support:
%%%%%%%%%%%%%%%%%%%%%
%        x = [randn(30,1); 5+randn(30,1)];
%        xi = linspace(-10,15,201);
%        f = ksdensity(x,xi,'function','cdf');
%%%%%%%%%%%%%%%%%%%%%

% %II. Graph - Combined DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %standard call:
% [f,xi] = ksdensity(x, 'support', [0,1]);
% plot(xi,f);

%Put all 64 Farms together
figure(1)
[fA,xiA] = ksdensity(A, 'support', 'positive');
[fB,xiB] = ksdensity(B, 'support', 'positive');
[fC,xiC] = ksdensity(C, 'support', 'positive');
% plot(xiA,fA)
% hold on
% plot(xiB,fB)
% hold on
% plot(xiC,fC)
% legend('1-avg','2-avg','3-avg')

linenu = 2;

plot(xiA,fA,xiB,fB,xiC,fC, 'LineWidth',linenu);
legend('1-avg','2-avg','3-avg')
xlabel('Egg Count', 'fontsize',14)
ylabel('Probability Density', 'fontsize',14)




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.