フィルターのクリア

exist function terminates script

1 回表示 (過去 30 日間)
John Knowles
John Knowles 2016 年 6 月 29 日
編集済み: Stephen23 2017 年 1 月 7 日
After an if-exist block, why does script stop executing? In example below the code never gets to the final line. I feel that regardless of the state of the if block, the final line should execute. If I comment out the if and end lines, then I do get to the final line.
IniParamFlag=1;
if exist('Params','var')==1,
IniParamFlag=menu('Initialize parameters','yes','no');
end
IniParamFlag
  3 件のコメント
John Knowles
John Knowles 2016 年 6 月 30 日
Interesting. What version are you using? I'm on MATLAB Version: 8.6.0.267246 (R2015b). I find that if the condition evaluates to '1', then the code inside the if/end is executed, but nothing after the end. If instead it evaluates to zero, then nothing further is executed.
Adam
Adam 2016 年 6 月 30 日
R2016a

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2016 年 6 月 29 日
You appear to have a control-Z immediately after your 'end' as the very next character.
  5 件のコメント
John Knowles
John Knowles 2017 年 1 月 7 日
編集済み: John Knowles 2017 年 1 月 7 日
Thank you Walter and Image Analyst for taking the time to explain this. I somehow missed your last replies until now, when I got hit with a new instance of the problem. You were exactly right and the problem is now solved.
Stephen23
Stephen23 2017 年 1 月 7 日
編集済み: Stephen23 2017 年 1 月 7 日
This is a good example of where Notepad++ is an extremely handy text editor to have around: the menu View -> Show Symbol has a number of options, and makes finding bugs like this one easy.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by