필터 지우기
필터 지우기

Curve Fitting Error with MATLAB sample codes

조회 수: 16 (최근 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 CenterFile Exchange에서 Get 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