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

2 次查看(过去 30 天)
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 个评论
Rik
Rik 2017-5-23
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)?

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2017-5-23
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 个评论
David Soltysik
David Soltysik 2017-5-25
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by