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!