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

80 ビュー (過去 30 日間)
Felix Bechtle
Felix Bechtle 2025 年 10 月 13 日 14:05
コメント済み: Sam Chak 2025 年 10 月 14 日 7:05
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 件のコメント
Steven Lord
Steven Lord 2025 年 10 月 13 日 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 2025 年 10 月 13 日 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.

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2025 年 10 月 13 日 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 件のコメント
Sam Chak
Sam Chak 2025 年 10 月 14 日 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 .

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

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品


リリース

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by