Fit the Data to a Quadratic Function with a y-offset (y = b+mx^2) error

7 Ansichten (letzte 30 Tage)
How do I fix this error code?
Data Set:
Here is a data set with uncertainties in y-direction
clear
X=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
Y=[4.2,7.5,19.5,32.8,54.2,80.9,112.2,154.5,197.1,248.0,306.3];
dY=[3.2, 5.4, 8.5, 14.6, 23.6, 32.7, 40.7, 41.8, 34.8, 37.9, 23.9];
Fit the Data to a Quadratic Function with a y-offset (y = b+mx^2)
linear_fit='b+m*x^2';% INSERT CODE HERE TO DEFINE THE FIT FUNCTION
start_values=[1.0,4.0];% INSERT CODE HERE TO CREATE THE START VALUES
[f1,gof1]=fit(X',Y',linear_fit,'Start',start_values)% INSERT CODE HERE TO APPLY THE FIT FUNCTION
!Check for missing argument or incorrect argument data type in call to function 'fit'.

Akzeptierte Antwort

Matt J
Matt J am 16 Okt. 2020
Bearbeitet: Matt J am 16 Okt. 2020
I get no error messages when I run your code. However, you do not need fit() to perform this fit. You can just use polyfit,
p=polyfit(X.^2,Y,1);
m=p(1);
b=p(2);
  2 Kommentare
Matt J
Matt J am 16 Okt. 2020
You're quite welcome, but please Accept-click the answer to indicate that it addressed the problem.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Quadratic Programming and Cone Programming 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