Curve Fitting Toolbox: 1. Why using this mentioned curve equation, I am not getting back the same curve or can't get nearby value for in between points? 2. How matlab calculates f(xi), may be I that can also useful to me?
Show older comments
For my experimental data points on x-axis [300.00 310.00 320.00 330.00 340.00 350.00 360.00 370.00 380.00 390.00 400.00 410.00 420.00 430.00 440.00 450.00 460.00 470.00 480.00 490.00 500.00 510.00 520.00 530.00 540.00 550.00 560.00 570.00 580.00 590.00 600.00 610.00 620.00 630.00 640.00 650.00 660.00 670.00 680.00 690.00 700.00 710.00 720.00 730.00 740.00 750.00 760.00 770.00 780.00] and for Y-axis [0.00 0.00 0.00 0.00 0.00 0.01 0.02 0.02 0.03 0.04 0.05 0.06 0.07 0.07 0.08 0.09 0.10 0.10 0.11 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.17 0.17 0.17 0.17 0.17 0.16 0.15 0.15 0.15 0.14 0.14 0.12 0.10 0.08 0.06 0.05 0.03 0.02 0.01 0.02]. Later I plotted and tried to fit curve. So for 6th or 7th polynomial fit I got equation for 92-points (but here pasted 52 points bcaz for other points value is near zero) with coefficient: f=(-2.751e-024)*x^9 + 1.863e-020*x^8 + (-5.473e-017)*x^7 + 9.149e-014*x^6 + (-9.589e-011)*x^5 + 6.534e-008*x^4 + (-2.893e-005)*x^3 + 0.008026*x^2 + ( -1.264)*x + 85.95. Next when I used 'Analysis' and plotting value for function i.e. f(xi) and xi=300:10:780; plotted curve for x-values and f(xi); matching very well. So my Question is: 1. Why using this mentioned curve equation, I am not getting back the same curve or can't get nearby value for in between points? 2. How matlab calculates f(xi), may be I that can also useful to me?
3 Comments
dpb
on 14 Sep 2013
Didn't follow the question/problem precisely...amplify on 1) specifically.
Note the magnitude of the higher coefficients--these are tiny values in comparison to those of the remainder. You'll have much more stable estimates in all likelihood if you standardize the data.
I did
>> [p,s]=polyfit(x,y,9);
Warning: Polynomial is badly conditioned. Add points with distinct X
values, reduce the degree of the polynomial, or try centering
and scaling as described in HELP POLYFIT.
> In polyfit at 76
>> [P,S,M]=polyfit(x,y,9); % fit standardized
>> yhat=polyval(p,x); % evaluate non-standardized model
>> plot(x,y,'x'), hold on, plot(x,yhat,'r-')
>> Yhat=polyval(P,(x-M(1))/M(2)); % evaluate standardized model
>> plot(x,Yhat,'g-') % add to plot as well...
>> Yhat=polyval(P,([x(1):x(end)]-M(1))/M(2)); % evaluate more points
>> plot([x(1):x(end)],Yhat,'kx') % and add them
>>
While I'd not advocate using such high order polynomial and you definitely won't want to try to use it to extrapolate beyond the given data range, it seems to reproduce the given data pretty well, considering.
You might actually consider a smoothing spline instead, however, owing to the two end conditions it shouldn't have quite the overshoot the polynomial does.
dhiraj
on 14 Sep 2013
dpb
on 15 Sep 2013
I have no idea what you're after above -- why not standardize and just use polyval() directly to get the better numerics?
Answers (0)
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!