Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Rik
Rik il 23 Mag 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)?

Accedi per commentare.

Risposte (1)

Jan
Jan il 23 Mag 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 Commento
David Soltysik
David Soltysik il 25 Mag 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

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown 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