Curve fit such as f(x) = A + B/x^2

5 ビュー (過去 30 日間)
Peter Burda
Peter Burda 2020 年 10 月 10 日
コメント済み: Ameer Hamza 2020 年 10 月 10 日
Hi, my problem is that I need fit curve such as f(x) = A + B/x^2 in matlab any suggestions?
thanks

回答 (3 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 10 日
編集済み: Ameer Hamza 2020 年 10 月 10 日
If you have optimization toolbox then you can use lsqcurvefit()
x; % x-values
y; % f(x) values
mdl = @(p, x) p(1) + p(2)./x.^2;
sol = lsqcurvefit(mdl, rand(1,2), x, y);
A = sol(1);
B = sol(2);
You can also check fit() from Curve fitting toolbox.
  2 件のコメント
Peter Burda
Peter Burda 2020 年 10 月 10 日
編集済み: Peter Burda 2020 年 10 月 10 日
thanks mate but what does mean rand(1,2)?
Ameer Hamza
Ameer Hamza 2020 年 10 月 10 日
It is just a starting point for the algorithm.

サインインしてコメントする。


Matt J
Matt J 2020 年 10 月 10 日
編集済み: Matt J 2020 年 10 月 10 日
p=polyfit(1./x.^2,y,1);
B=p(1);
A=p(2);

Matt J
Matt J 2020 年 10 月 10 日
編集済み: Matt J 2020 年 10 月 10 日
p=((1./x(:)).^[0,2]) \ y(:);
A=p(1);
B=p(2);

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by