Issues with polynomial fit

4 Ansichten (letzte 30 Tage)
Adil Hussain
Adil Hussain am 24 Jan. 2020
Kommentiert: Walter Roberson am 27 Jan. 2020
I have a problem coding the best fit for these data
D=[0.5 5 10 100 1000];
y1=[1.56 2.12 4.34 7.13 10.22];
y2=[1.3 2.08 4.1 6.45 12.93].';
Thois below is the output
The polynomial fit works well for large values but for small values of D (e.g 0.5, 5) which is x-axis in my case, its weird. Please suggest me some best fit for this data. I made this code but it is not efficient
D=[0.5 5 10 100 1000].';
y1=[1.56 2.12 4.34 7.13 10.22].';
y2=[1.3 2.08 4.1 6.45 12.93].';
p1 = polyfit(D,y1,1); x1 = 0.5:0.001:1000; z1 = polyval(p1,x1);
'MarkerSize',6); hold on;
'MarkerSize',6); hold on;
p2 = polyfit(D,y2,1); x2 = 0.5:0.001:1000; z2 = polyval(p2,x2);
axis([0.5 1000 0.0 14]);

Akzeptierte Antwort

Spencer Chen
Spencer Chen am 24 Jan. 2020
You are fitting an order-1 polynomial, i.e. linear, so it is a bad fit. Try higher orders. But it looks like a different function will fit your data better.
  2 Kommentare
Adil Hussain
Adil Hussain am 27 Jan. 2020
Thanks for your answer. I tried for higher order polynomial but they get more worse. I need something linear but not like order-1 polynomial. Could you please suggest me some function for it?
Walter Roberson
Walter Roberson am 27 Jan. 2020
"Linear" and "order 1 polynomial" are the same.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)


Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by