Curve Fitting Error with MATLAB sample codes

33 ビュー (過去 30 日間)
Brent Majcher
Brent Majcher 2022 年 3 月 6 日
コメント済み: Zeyu Ma 2023 年 9 月 11 日
Hi everyone,
I am trying to run the fit.m script using the example codes (https://www.mathworks.com/help/curvefit/fit.html#d123e30780).
The script is:
load census;
f=fit(cdate,pop,'poly2')
This is giving me the following errors and I don't know why.
Not enough input arguments.
Error in checkbounds (line 26)
if lenlb > nvars
Error in fit>iFit (line 275)
[lowerbnd, upperbnd, anError, aWarning] = checkbounds( lowerbnd, upperbnd, numcoeff );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Can anyone shed some light on this?
  • The cdate and pop matrices data do import as 21x1 (double)
  • This same error happens when I define simple linear x and y relationship, so it's not a problem with the data (I don't think)...
  • Is it possible there is errors in the fit.m?
  2 件のコメント
Torsten
Torsten 2022 年 3 月 6 日
編集済み: Torsten 2022 年 3 月 6 日
Is it possible that you don't have a licence for the Curve Fitting Toolbox ?
Try
license checkout Curve_Fitting_Toolbox
in the command window.
What does MATLAB return ?
Zeyu Ma
Zeyu Ma 2023 年 9 月 11 日
I encountered the same problem and got an error message like this
Not enough input arguments.
Error in checkbounds (line 26)
if lenlb > nvars
Error in fit>iFit (line 275)
[lowerbnd, upperbnd, anError, aWarning] = checkbounds( lowerbnd, upperbnd, numcoeff );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in torquescripts.field (line 589)
myfit = fit(xq', yq', myfittype, StartPoint = [amps,mean(yq)])
However, my code worked perfectly fine last night. I can't think of anything I did today that would possible cause this problem.
I did change the path but now I set it to default and still got this problem.

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

回答 (1 件)

Jonas Björklund Svensson
Jonas Björklund Svensson 2022 年 9 月 29 日
Hi all,
I get the exact same error in a piece of code that used to work (I'm running 2021a). I get the error even with a simple
fit([1,2,3]', [1,2,3]', 'poly1')
I checked all of the suggested fixes - I have the curve fitting toolbox licence, and I get the expected output when checking the fit type. This is an extremely puzzling error. I previously had trouble with fitting in an earlier version because somehow the fit function had been replaced by another with the same name (not by me...), but this doesn't seem to be the case now.
I would really like to avoid reinstalling matlab again because of this. Are there any other ideas?
Best regards,
Jonas

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by