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
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 个)

类别

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