Calculating Residuals from polyfit
Show older comments
I just wanted to check that I am calculating residuals correctly as I am gettign a different answer compared to mathcad. M is my matrix of data, of which I plot column 1 (x-axis) against column 5 (y axis)
I am performing both 3rd and 5th order polynomial fits
x=M(:,1);
y=M(:,5);
p3=polyfit(x,y,3);
f3=polyval(p3,x);
p5=polyfit(x,y,5);
f5=polyval(p5,x);
plot(x,f3,'b--')
plot(x,f5,'g--')
legend('Zmx','3rd','5th')
%Calc Residuals
y3=y-f3;
y5=y-f5
axes(handles.axes2)
cla
plot(x,y3,'bd--','MarkerSize', 3)
grid on
hold on
plot(x,y5,'rd--','MarkerSize', 3)
legend('3rd','5th')
Is that correct for the residuals e.g. y3 = y-f3 ?? thanks Jason
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!