フィルターのクリア

Strange results using Curve Fitting tool

4 ビュー (過去 30 日間)
Sergio
Sergio 2020 年 11 月 1 日
編集済み: Sergio 2020 年 11 月 1 日
Hello,
I'm trying to fit a function of the type "a1*cos(b1*x+c1) + a2*cos(b2*x+c2)" to my data using the curve fitting tool -> custom equation. However, the fitting results are terrible (since I know the data, I know the results should be reasonably good).
Thus, I tested the function "a1*sin(b1*x+c1) + a2*sin(b2*x+c2)" and the results remain terrible! The weirdest thing, though, is that when I use the "sum of sine" option (which is the exact same thing) the results are great, as expected.
Any ideas?
  2 件のコメント
Matt J
Matt J 2020 年 11 月 1 日
If the "sum of sine" option worked, why do you still require a custom solution?
Sergio
Sergio 2020 年 11 月 1 日
To verify if I was inputting the custom function correctly.

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

回答 (1 件)

Matt J
Matt J 2020 年 11 月 1 日
編集済み: Matt J 2020 年 11 月 1 日
Not many, since without your data and code, we cannot reproduce what you are seeing. One possible culprit though is the initial guess of the parameters. If you're going to use a custom model, you need to supply your own strategy for selecting an initial guess, since Matlab has no educated way of choosing one automatically for a custom equation. Since you did not mention any such strategy, I can only assume you just let the curve fitter pick an arbitrary initial guess, and that can certainly lead to poor results.
Also, I would recommend that you parametrize the equation terms asymmetrically, so that the solver can distinguish between the them, e.g., "a1*cos(b1*x+c1) + (a1+a2)*cos(b2*x+c2)"
  5 件のコメント
Matt J
Matt J 2020 年 11 月 1 日
Thiw worked,
>> ffit=fit(x,y,ft,'StartPoint',[1 1 0.74 0.064 -2.797 3.059] );
>> plot(ffit,x,y);scf
Sergio
Sergio 2020 年 11 月 1 日
It sure did! It was the order of the starting parameters, right?
Thanks a lot for your help!

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by