The first real example of graph usage
% OK for the next example you have a bunch of empirical data like this:%A = [11 42 141 587 2093 7792 23643 93437 331519]; S = [1.0759 0.5925 0.3407 0.1796 0.1089 0.0621 0.0340 0.0272 0.0155]; %% let us see if we can make any sense of it.% first lets plot it%figure(1);subplot(2,2,1);plot(A,S,'b');legend({'raw plot'})%% not easy to see what is going on% now let's look on the log log plot of the data:%subplot(2,2,2);loglog(A,S,'c')legend({'loglog plot'})%% which looks far more useful% we will plot this again in a slightly % different way%subplot(2,2,3);ALog = log10(A);SLog = log10(S);plot(ALog,SLog,'ko');legend({'plot of log values'})%% it certainly looks linear in loglog space!% which means it has the form% S = K*A^M% it would be very easy to fit a line to the loglog plot using polyfit%pfit = polyfit(ALog, SLog,1);%% this gives us a K value of 10^0.4247 = 2.6589 (remember we are in log% space) and the best-fit slope of -0.41%% we can plot the fitted line in red next to the experimental points%subplot(2,2,4);xVals = 0:0.5:max(ALog);wrong_yVals = polyval(pfit,xVals);plot(ALog,SLog,'ko'); hold on;plot(xVals,wrong_yVals,'r');legend({'data' '[-0.41,0.42]'})