Best tool to calculate the parameters of a custom equation fit

12 ビュー (過去 30 日間)
Birsen Ayaz-Maierhafer
Birsen Ayaz-Maierhafer 2022 年 7 月 7 日
編集済み: Matt J 2022 年 7 月 14 日
Hello,
There are quite a bit merhods/tools to fit an custom equation to the experimantal data. I am struggling to use the right one (I tried many of them and eventually decided to ask to an expert). My custom equation is (a+b/x^2)*exp(-x/c). What is the best way to find a,b and c if you really don't know what the starting parameter values are.
Thank you
Birsen

採用された回答

Matt J
Matt J 2022 年 7 月 7 日
編集済み: Matt J 2022 年 7 月 7 日
For your particular equation, I'd rcommend,
[a,b,c]=deal(3,2,1)
a = 3
b = 2
c = 1
x=linspace(1,2,30); %fake data
y=a+b./x.^2.*exp(-x/c);
funlist={1,@(c,x) exp(-x/c)./x.^2};
[c,ab]=fminspleas(funlist,2, x,y);
a=ab(1), b=ab(2),c %fitted values
a = 3
b = 2
c = 1.0000
yfit=a+b./x.^2.*exp(-x/c);
plot(x,y,'x',x,yfit); legend('Sample Data','Fit')
  2 件のコメント
Birsen Ayaz-Maierhafer
Birsen Ayaz-Maierhafer 2022 年 7 月 11 日
Hi Matt,
Thank you, that seems very promising. My equation indeed is (I posted wrong but I corrected it immediatly after that)
y=(a+(b/x^2))*exp(-x/c);
I am trying to understand what you did with funlist below. Would it be the same with the updated equation? You are passing only one parameter c, not the others.
funlist={1,@(c,x) exp(-x/c)./x.^2 };
In the following you are passing funlist and the number "2". Is that c and ab?
[c,ab]=fminspleas(funlist,2, x,y);
Thank you
Birsen
Matt J
Matt J 2022 年 7 月 11 日
編集済み: Matt J 2022 年 7 月 14 日
Would it be the same with the updated equation?
I don't see any change in the equation since I posted. But yes, the fminspleas algorithm only iterates over c (and only requires an initial guess for c) in your case, because that is the only parameter that the model equation has a nonlinear dependence. on.

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

その他の回答 (1 件)

Kevin Holly
Kevin Holly 2022 年 7 月 7 日
Have you tried using the Curve Fitting Toolbox? You can fit your custom equation to a set of data and it will provide you with the coefficients that provide the best fit along with statistical metrics and a plot.
  1 件のコメント
Birsen Ayaz-Maierhafer
Birsen Ayaz-Maierhafer 2022 年 7 月 7 日
Hi Kevin, thank you. i tried that tool. It really did not work.The curvefit tool box plot does not come with log scale and you really can't see if the fit is good or not. It gave me answers but when I used the parameters and plot outside of curve fitting tool box the data it was way out of fitting.

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

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by