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 CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by