Hello,
I have a (maybe very simple) problem with polyfit and I hope its not just a stupid misunderstanding of the polyfit function. I use polyfit inside a much more complex algorithm and I just realized, that the results from polyfit are quite bad and I wondered why so I tried a minimal example :
x = -1:0.001:+1;y= -10*x.^2 +5 - 0.1*(x)+rand(size(x))*0.001;[p,S,mu] = polyfit(x,y,2);[y_polyval, delta] = polyval(p,x,S);plot(x,y,x,y_polyval,'r');
The plot shows, that the fit is quite different from the original data. Its a very simple data set and I don't understand why polyfit returns so bad results.
Would be very grateful for a helpful advice.
EDIT: This is what I get :
Best Answer