Stop script execution when I press pushbutton

Hello,
I would like to get a pushbutton to stop execution of my script. But my code doesn't work:
Stp = uicontrol('Style', 'pushbutton', 'Callback', 'stop', 'Units', 'normalized', 'Position', [0.2 0.85 0.05 0.1], 'Enable', 'on');
I tried also with "break" and "return" as Callback function but It doesn't work.
My script has simply an initialization part and a while loop I tried also to put code above inside while loop but it's the same.
thanks

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 10 月 13 日

0 投票

About the only chance you would have would be with stop or quit, which would close MATLAB entirely.
There is no mechanism in MATLAB to force an executing script to be interrupted. The closest you can get is to have the cooperation of the script, which must check from time to time whether an interruption is desired.

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

タグ

質問済み:

2012 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by