x=[0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0]
y=[6.00 4.83 3.70 3.15 2.41 1.83 1.49 1.21 0.96 0.73 0.64]
xdata=x
ydata=log(y)
A=[sum(xdata.^2) sum(xdata);
sum(xdata) length(xdata)];
C=[sum(xdata.*ydata);
sum(ydata)];
vec=inv(A)*C;
a=vec(1); %this should be m
b=vec(2); % this should be ln(p)
a=m;
p=exp(b);
xplot=linspace(0,5);
yplot=p*exp(m*xplot);
hold off
plot(x,y,’ko’,’MarkerSize’,15,’MarkerFaceColor’,’g’)
hold on
plot(xplot,yplot,’k-‘,’LineWidth’,2)
xlabel(‘x’);
ylabel(‘y’);