필터 지우기
필터 지우기

Custom equation error in fitting toolbox

조회 수: 1 (최근 30일)
Pietro Scapolo
Pietro Scapolo 2021년 12월 10일
댓글: Pietro Scapolo 2021년 12월 10일
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by