Polynomial fit through a certain point

hello,
I just started using matlab and i wanna do a curve fitting, i got a curve but it doesnt go through any point ... and i wanna make it at least go through (11.483,4) (11.507,1) (11.525,4.81) how can i do that ?
also if you have any advices on how to make the curve even better that'll be great !
thanks a lot
x=[11.42, 11.46, 11.48, 11.483, 11.49, 11.495, 11.5, 11.505, 11.507, 11.51, 11.515, 11.52, 11.525, 11.56, 11.6 ]
y=[-15.54, -11.5, -5.4, -4, -3.11, -2.23, -1.46, -1.02, -1, -1.24, -2.18, -3.5, -4.81, -7.92, -14.56]
p = polyfit(x,y,2)
x1 = linspace(11.42,11.6);
y1 = polyval(p,x1);
figure
plot(x,y,'or')
hold on
plot(x1,y1)
hold off

回答(1 个)

You want to fit a quadratic polynomial through your data, but you also want to force it through 3 other data points? SIGH.
A quadratic polynomial has only three parameters. THREE. 3. The number 3.
There is only one quadratic polynomial that wil pass exactly through 3 points, since there are 3 unknowns to estimate. So a least squares fit of a quadratic to your data is meaningless here.

此问题已关闭。

标签

关闭:

2018-12-9

Community Treasure Hunt

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

Start Hunting!

Translated by