Professional Documents
Culture Documents
clc;
close;
clear;
x=[2 4 6 8];disp([x]);
y=[25 38 56 84];disp([y]);
//n=length of x
n=4;
Y=log(y);disp([Y]);
X=x;disp([X]);
X2=X.*X;disp([X2]);
XY=X.*Y;disp([XY]);
a0=(sum(Y)*sum(X2)-sum(X)*sum(XY))/(n*sum(X2)-
(sum(X)^2));
a1=(n*sum(XY)-sum(X)*sum(Y))/(n*sum(X2)-(sum(X))^2);
a=exp(a0);
b=a1;
printf('\ny=%f*e^%f*x',a,b);
solution=
2. 4. 6. 8.
2. 4. 6. 8.