Why do I get the error message: "Undefined function 'isinf' for input arguments of type 'struct'."?
4 次查看(过去 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
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
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!