Why do I get the error message: "Undefined function 'isinf' for input arguments of type 'struct'."?

2 vues (au cours des 30 derniers jours)
I tried running the example code to fit data to an exponential function, found here - https://www.mathworks.com/help/curvefit/confidence-and-prediction-bounds.html:
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.5*randn(size(x));
fitresult = fit(x,y,'exp1');
MATLAB failed to execute the code, instead giving me the following error message:
Error using fit>iFit (line 340)
Undefined function 'isinf' for input arguments of type 'struct'.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
I have the curve fitting toolbox installed, so I don't know why it's not working.
Thanks for any advice.
David
  4 commentaires
Rik
Rik le 23 Mai 2017
On R2015a (CFT v3.5.1) this code works as well. It may be grasping at straws, but did you overlook stuff like accidentally re-defining functions like exp or size?
Or something that shouldn't have any effect on this: did the problem persist after a restart of Matlab (or even a system reboot)?

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 23 Mai 2017
You can check the type of the variables:
x = (0:0.2:5)';
y = 2*exp(-0.2*x) + 0.5*randn(size(x));
class(x)
class(y)
Are these double vectors as expected?
If this you might have overlaoded another function. Use the debugger to see, what's going on:
dbstop if error
Then run the code again until it stops at the error. Then check to contents of the variable, which has provided to the failing isinf command. What do you see inside this struct? Does it ring any bell?
  1 commentaire
David Soltysik
David Soltysik le 25 Mai 2017
Thanks for the advice.
I tried "dbstop if error", and it pointed me toward a line in the code, but I couldn't figure out what was wrong. I don't think "isinf.m" was overloaded because the help command appeared normal. But maybe something else was.
Next, I tried reinstalling MATLAB (this time R2017a), but the error was still present. In fact, I couldn't examine the path (pathtool stopped working).
So, then I did "restoredefaultpath." Following this, the "fit" command finally worked.
David

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by