Curve Fitting Toolbox Error: This expression has no coefficients or non-scalar coefficients.

80 views (last 30 days)
Hi, i want to use the curve fitter with the custome equation:
y(x)=y0*((sin(n*a*(sin(x)/b)*pi))/sin(a*(sin(x)/b)*pi))^2*sinc((sin(x)/b)*pi*c)^2 with n = 5; a = 30e-6; b = 450e-9; c = 450e-9
My data has the following form:
0;3140
1;3073
...
24;3232
25;3349
I always recieve the error message
Fit Name: untitled fit 1
Error: This expression has no coefficients or non-scalar coefficients.
Warning: Ignoring NaNs in data.
  10 Comments
Steven Lord
Steven Lord on 13 Oct 2025 at 20:47
What do you know and what are the parameters that Curve Fitting Toolbox can adjust to fit the equation to the data?
Knowns:
  • x is the independent variable
  • y is the dependent variable
Not sure if known or parameter:
  • y0
  • N
  • d
  • λ
  • b
You may also need to be careful to avoid division by 0: lambda can't be 0, x can't be a multiple of pi, etc.
Walter Roberson
Walter Roberson on 13 Oct 2025 at 21:13
The curve fitting toolbox does not handle restriction of a parameter to be an integer.
It would be better if you counted the pulses first and used that as your N.

Sign in to comment.

Answers (1)

Cris LaPierre
Cris LaPierre on 13 Oct 2025 at 20:43
As has been pointed out, you have to give the app some coeffients to adjust to try to fit to. Also note that your proposed coefficient values are extremely small. You will need to do some tweaking of fit settings to get results at that scale.
The other challenge you will have is that the equation evaluates to NaN at y=0, which will also throw an error.
Try this to at least get rid of the errors.
% Equation
3140*(((sin(5.*a.*(sin(x)./b).*pi))./sin(a.*(sin(x)./b).*pi)).^2).*(sinc((sin(x)./b).*pi.*c).^2);
  • Add an exclusion rule to ignore x<1.
At this point, the curve fitter should start fillting a,b, and c. The results I get are not very good, though.
  1 Comment
Sam Chak
Sam Chak on 14 Oct 2025 at 7:05
Despite the proposed fitting model being undefined (NaN) at , both the left-hand and right-hand limits as exist and are equal.
syms a b c N x y0
f = y0*(((sin(N*a*(sin(x)/b)*pi))/sin(a*(sin(x)/b)*pi))^2)*(sinc((sin(x)/b)*pi*c)^2)
f = 
limit(f, x, 0)
ans = 
If the fitting model is intended to be continuous at 0, then it must satisfy based on the data point .

Sign in to comment.

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!