curve fitting a custom equation
古いコメントを表示
a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x)
This is the equation i'm trying to fit using the custom fit tool. Since the variable x is both in exponential and linear form, the data isn't really fitting, it's just a straight line. Is there way to fit the data to this equation? 

As a side note: how do I view the numerical values instead of scientific ones in curve fitting tool?
Thank you
1 件のコメント
In the first line of your post, you show the model equation as,
a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x)
However, in your screenshot of the cftool app, the model equation appears instead as,
a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x)
You should edit your post so that we know which version of the equation is the intended one.
採用された回答
その他の回答 (1 件)
Matt J
2021 年 7 月 15 日
1 投票
You don't need a custom type. Your model is just exp2 but with modified data (x,y-x)
11 件のコメント
Ayushi Sharma
2021 年 7 月 15 日
Ayushi Sharma
2021 年 7 月 15 日
OK. So first, I would reparametrize your model more simply as follows,
A*exp(-x/T)+c*(x-1)
Then I would use fminspleas from the File Exchange to solve this. Because only T affects the model non-linearly, it should do a good job with this model assuming you have a decent initial guess T0 for T.
funlist={ @(T,x)exp(-x/T) , @(T,x) (1-x) }
[T,Ac]=fminspleas(funlist, T0, x,y, 0);
c=Ac(2);
a=Ac(1)-c*T;
If you still need a Curve Fitting Toolbox result, you can at least use the results of fminspleas to provide the cftool app an initial parameter guess. That should help it reach a more accurate fit with your custom equation.
Alex Sha
2021 年 7 月 16 日
Hi, Sharma, the result you got is actual a local solution, not global one. The result below is the correct one
Root of Mean Square Error (RMSE): 15137803.4043152
Sum of Squared Residual: 4.58306183815394E15
Correlation Coef. (R): 0.996383637520966
R-Square: 0.992780353119513
Parameter Best Estimate
---------- -------------
t -1.72718650949557
a -54592639.7090172
c -31608221.6797308

Ayushi Sharma
2021 年 7 月 16 日
Ayushi Sharma
2021 年 7 月 16 日
First, you have mistyped your model function in your original post.
Second, the segment of data in doubt.mat is too linear to capture the exponential trends in the function. There are basically two solutions for T, which are T=0 and T=-1 both of which allow the solution ot degenerate to a linear fit. Here is what I get when initializing at T=1;
funlist={@(T,x)exp(-x*T), @(T,x) T*(exp(-x/T)-1)+x };
[T,ac]=fminspleas(funlist,1, x,y,0);
a=ac(1); c=ac(2);
fun=@(x) a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x);
plot(x,y,'o', x,fun(x));
a,c,T
a =
-6.2820e+07
c =
-2.9980e+07
T =
1.0481e-14

Ayushi Sharma
2021 年 7 月 16 日
Walter Roberson
2021 年 7 月 16 日
Alex uses a commercial program named 1stOpt from 7d-soft. It costs roughly $2000 for a license. That is, of course, not exactly "cheap"; however, having seen the results Alex has posted on a number of different problems, I would say that if you do curve fitting, that it does a very nice job. I can sometimes improve slightly over the results it gets, but only after at least an hour of work.
Thank you so much for your input. I have opted for this method.
@Ayushi Sharma You're welcome, but please Accept-click the answer if you consider the question addressed.
Alex uses a commercial program named 1stOpt from 7d-soft. ... I would say that if you do curve fitting, that it does a very nice job.
However, the fit Alex has shown us is based on an incorrect model equation, because @Ayushi Sharma had a typo in the first line of his post. If we substitute Alex's parameter estimates into the true model, it gives strong disagreement with the data:
load doubt
a=-54592639.7090172;
c=-31608221.6797308;
T=-1.72718650949557;
fun=@(x) a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x);
plot(x,y,'o'); ax=axis;
hold on
plot( x,fun(x));
hold off
axis(ax)
legend('Data','Fit')

カテゴリ
ヘルプ センター および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



