Could someone please help me with the format on entering thi

Could someone please help me with the format on entering this in Matlab?

Thank you greatly!


Solution

1)a)i)

x = [5 10 15 20 25 30 35 40 45 50];
y =[17 24 31 33 37 37 40 40 42 41];
N = 1;
P = polyfit(x, y, N)
xmodel = linspace(min(x), max(x), 100);
yhat = polyval(P, x);
ymodel = polyval(P, xmodel);
St = sum(( y - mean(y) ).^2)
Sr = sum(( y - yhat ).^2)
r2 = (St - Sr) / St


ii) x = [5 10 15 20 25 30 35 40 45 50];
y =[17 24 31 33 37 37 40 40 42 41];
xmodel = linspace(min(x), max(x), 100);
yeqn = @(coefs, x) coefs(1).*x.^coefs(2);
xi = log10(x);
eta = log10(y);
P = polyfit(xi, eta, 1);
MyCoefs(1) = 10^(P(2));
MyCoefs(2) = P(1)
yhat = yeqn(MyCoefs, x);
ymodel = yeqn(MyCoefs, xmodel);
St = sum(( y - mean(y) ).^2)
Sr = sum(( y - yhat ).^2)
r2 = (St - Sr) / St


(iii)x = [5 10 15 20 25 30 35 40 45 50];
y =[17 24 31 33 37 37 40 40 42 41];
xmodel = linspace(min(x), max(x), 100);
yeqn = @(coefs, x) coefs(1).*x./(coefs(2)+x);
xi = 1./x;
eta = 1./y;
P = polyfit(xi, eta, 1);
MyCoefs(1) = 1/P(2);
MyCoefs(2) = P(1)/P(2)
  
yhat = yeqn(MyCoefs, x);
ymodel = yeqn(MyCoefs, xmodel);
St = sum(( y - mean(y) ).^2)
Sr = sum(( y - yhat ).^2)
r2 = (St - Sr) / St

Could someone please help me with the format on entering this in Matlab? Thank you greatly! Solution1)a)i) x = [5 10 15 20 25 30 35 40 45 50]; y =[17 24 31 33 3

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site