How to run and pause script from ui button

I want to have a ui button that will start and pause a simulation. The script I want to run is a for loop simulation, say the script name is simulation.m.
I set the push button as follows.
start.button = uicontrol('Style','pushbutton','units','normalized',...
'String','Start','Position',[0.1,0.93,0.1,0.05], ...
'Callback',@start_call);
function [] = start_call()
simulation.m;
I can't figure out what to write in the callback function (either for running the script or for pausing it

回答 (1 件)

Stephen23
Stephen23 2015 年 9 月 15 日
編集済み: Stephen23 2015 年 9 月 15 日

0 投票

Try downloading my FEX submission and running the file "cubehelix_view":
This function creates a figure containing several axes, sliders and buttons. The button labeled "Demo" will turn on and off a looped demonstration mode. You can have a look at the code to see how it works, but the basic idea is to check the button's values on each loop iteration:
% Check if the toggle button is down:
while ishghandle(tgh)&&get(tgh,'Value')
% do stuff here
end

カテゴリ

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

タグ

質問済み:

2015 年 9 月 15 日

編集済み:

2015 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by