Script termination via uicontrol call function

7 ビュー (過去 30 日間)
Koustubh Shirke
Koustubh Shirke 2020 年 2 月 13 日
回答済み: Walter Roberson 2020 年 2 月 19 日
Hi ,
How can I terminate/ stop the script run through uicontrol callfunction ? I tried with some basic functions like break, return but it wont work
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 2 月 13 日
Koustubh - please provide some context. Are you starting a script from a GUI control callback function? Is this really a script or a function? What does it do? And why do you want to stop script from your GUI rather than letting it complete?
Koustubh Shirke
Koustubh Shirke 2020 年 2 月 19 日
Hi Goeff,
Thanks for the reply. Its a script. In that script I have written guicontrol function for pushbutton. If I press the button, the button name is 'Stope' which should ideallly stop the script to run further(In this case user wants to end up the script since he is satisfied with the reults). I hope this will helpufl you to understand the scenario which I want to implement.
please let me know if u need more info.
Regards,
Koustubh

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 2 月 19 日
You have four options to stop a script without its cooperation:
1) you can quit() MATLAB. Note that if you do this then onCleanup will still run and you will be asked about saving any changes in the editor
2) you can use Java Robot class to issue control C to the command line. In this particular context it should stop immediately (except perhaps some onCleanup) but in general control c can take hours before the command line gets control
3) you can force an out of memory error
4) you can force infinite recursion. MATLAB will notice and stop the program.
If you want a smooth termination of whatever is running then the only way to achieve that is with the cooperation of the program, with it having to check to see if stop was requested and deliberately ending computations early.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by