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

83 Ansichten (letzte 30 Tage)
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 Kommentare
Steven Lord
Steven Lord am 13 Okt. 2025 um 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 am 13 Okt. 2025 um 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 13 Okt. 2025 um 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 Kommentar
Sam Chak
Sam Chak am 14 Okt. 2025 um 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 .

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by