Why does the EXIST function return an incorrect value in stand-alone mode?
4 次查看(过去 30 天)
显示 更早的评论
Why does the EXIST function return an incorrect value in stand-alone mode?
Whenever I try to use the EXIST function in standalone mode, the wrong results are returned.
For instance the following code returns 0 in stand-alone mode:
function redbatmod
eat = 1;
exist('eat')
exist('flames')
采纳的回答
MathWorks Support Team
2009-6-27
The EXIST function has limitations for support in stand-alone mode. For more information, see the solution attached at the bottom of this page.
As a workaround, you can use either NARGIN or the following code, if you wish to check for the existence of a variable:
function texist2
nw = 2;
try
isempty(nw);
myexist=1;
catch
myexist=0;
end
fprintf(1,'exist: %d\n',myexist);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!