Azzera filtri
Azzera filtri

Curve Fitting Error with MATLAB sample codes

16 visualizzazioni (ultimi 30 giorni)
Brent Majcher
Brent Majcher il 6 Mar 2022
Commentato: Zeyu Ma il 11 Set 2023
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 Commenti
Torsten
Torsten il 6 Mar 2022
Modificato: Torsten il 6 Mar 2022
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 il 11 Set 2023
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.

Accedi per commentare.

Risposte (1)

Jonas Björklund Svensson
Jonas Björklund Svensson il 29 Set 2022
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

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by