Stopping timer object

I want to know if there's a way to stop a timer object while it is running, from my GUI,because I need matlab to be available during the timer execution to stop my experiment in any moment!
Thank you for attention

回答 (1 件)

Paulo Silva
Paulo Silva 2011 年 3 月 2 日

1 投票

If you have the timer handle
stop(timerhandle)
if not you can try
stop(timerfind)
or
stop(timerfindall)
or even
stop(findobj('type','timer'))
Also you might want to use
try
%expression to stop timers
catch
end
That's because you might get errors if there's no timer to be stopped

2 件のコメント

Oleg Komarov
Oleg Komarov 2011 年 3 月 2 日
To elaborate a little on Paulo's point you can place a pushbutton in your gui and a nested callback to stop the timer when the button is pressed:
pb = uicontrol('Style' ,'PushButton', 'Pos' ,[10 20 75 25],...
'String','STOP' , 'Call',@pb_call);
function @pb_call(varargin)
try
stop(findobj('type','timer'))
catch
end
end
Paulo Silva
Paulo Silva 2011 年 3 月 2 日
Thanks Oleg :)

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

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

質問済み:

2011 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by