Non-linear data fitting to a model
显示 更早的评论
I am trying to fit some data using the following code:
xdata = [0.0600 0.1250 0.2540 0.4050 0.5450];
ydata = [0.0800 0.1000 0.1200 0.1400 0.1600];
objfcn = @(x)(x(1)*x(2))./((x(2)*(1-xdata)./xdata)+(1-xdata)*(x(2)-1))-ydata;
x0 = rand(2,1);
opts = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt','Display','iter');
[x,resnorm]=lsqnonlin(objfcn,x0,[],[],opts);
M = x(1)
B = x(2)
I am getting results but sometimes M value is coming negative which is not desirable. Also, the predicted ydata deviates largely from the original ydata values. If someone could be help to analyze the small code mentioned above and what is the wrong with results.
Thanks,
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Least Squares (Curve Fitting) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!