CS计算机代考程序代写 x=[0.7860 1.5916 2.1917 2.9606 3.6441 4.2554 5.0294];

x=[0.7860 1.5916 2.1917 2.9606 3.6441 4.2554 5.0294];
y=[1.0113 4.4279 11.4360 22.2894 37.0793 56.9877 81.0653];

xt=log10(x);
yt=log10(y);

fitlm(xt,yt)

[a,b]=power_regression(x,y,[2,2]’)

x2 = linspace(0,6);

plot(x,y,’o’)
hold on
plot(x2,10^(0.22412)*x2.^2.3996)
plot(x2,a(1)*x2.^a(2))
hold off
function [a,out] = power_regression(x,y,a0)

tol = 10^-12;
a = a0;

d = [sum(2*a(1)*x.^(2*a(2))-2*(x.^a(2)).*y);
sum(2*a(1)^2*log(x).*(x.^(2*a(2)))-2*a(1)*log(x).*x.^(a(2)).*y)];

i = 1;

iter_max=500;

while max(abs(d))>tol && i= iter_max
out = 0;
else
out = 1;
end

end