Custom equation error in fitting toolbox
3 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/829815/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/829820/image.png)
2 个评论
Alex Sha
2021-12-10
Hi, post out your data if possible, it will be convenient for others to try your problem
采纳的回答
Chunru
2021-12-10
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 个评论
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!