Fit the Data to a Quadratic Function with a y-offset (y = b+mx^2) error
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Evve Land
am 16 Okt. 2020
Kommentiert: Matt J
am 16 Okt. 2020
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'.
0 Kommentare
Akzeptierte Antwort
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
am 16 Okt. 2020
You're quite welcome, but please Accept-click the answer to indicate that it addressed the problem.
Weitere Antworten (0)
Siehe auch
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!