Curve fit the given data set with an appropriate polynomial function

1 次查看(过去 30 天)
clear
clc
A=xlsread('Data.xls');
t=A(:,1);
y=A(:,2);
SST=sum((y-mean(y)).^2);
for i=1:3
fprintf('For %d order fit\n\n',i);
disp('Polynomial coefficients are');
C=polyfit(t,y,i)
SSR=sum((y-polyval(C,t)).^2);
R2=1-SSR/SST;
fprintf('R^2 is %f\n\n',R2);
end
for i=2:length(t)-1
T=[t(i-1) t(i) t(i+1)];
Y=[y(i-1) y(i) y(i+1)];
if(t(i)<33.75&&t(i+1)>33.75)
C=polyfit(T,Y,2);
disp('Value at 33.75 is ');
polyval(C,33.75)
return
end
end
Given this code, how would I include a plot of an appropriate polynomial fit from the excel document labeled "Data.xls"

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by