Fit the Data to a Quadratic Function with a y-offset (y = b+mx^2) error
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Matt J
2020-10-16
编辑:Matt J
2020-10-16
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 个评论
Matt J
2020-10-16
You're quite welcome, but please Accept-click the answer to indicate that it addressed the problem.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!