Custom equation error in fitting toolbox

Hi, I'm trying to fit my data with a specific function trough the fitting tool. The equation that my datas should fit is , it's the distribution of a laser light interference when it pass trought one fenditure.
By the way the fitting tool cannot fit my data, the error reported is: "NaN computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficient". I think the problem is cause by because when I dont add to the box there's no error.

2 件のコメント

Alex Sha
Alex Sha 2021 年 12 月 10 日
Hi, post out your data if possible, it will be convenient for others to try your problem
Pietro Scapolo
Pietro Scapolo 2021 年 12 月 10 日
Done! Thank you!

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

 採用された回答

Chunru
Chunru 2021 年 12 月 10 日

0 投票

The following function will result in undefined value for sin(x)=0
sin(a*sin(x))/(a*sin(x))
You can change this into sinc function (which take care of 0/0 case):
sinc(a*sin(x)/pi)
% which is equivalent to the first expression and eliminate the problem at
% sin(x)=0.
% doc sinc

3 件のコメント

Pietro Scapolo
Pietro Scapolo 2021 年 12 月 10 日
Thank you! I tried but it doesnt work, the curve it generates it's not the one I wanted... In the screenshot i put the numeric value because it corrispond to the max value of y.
Chunru
Chunru 2021 年 12 月 10 日
% The whole function should be
b*(sinc(a*sin(x)/pi)).^2
% the above is part of the function that cause the problem
Pietro Scapolo
Pietro Scapolo 2021 年 12 月 10 日
Thank you! It worked!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

リリース

R2021b

タグ

質問済み:

2021 年 12 月 10 日

コメント済み:

2021 年 12 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by