starting, stopping and waitFor in a timer

조회 수: 3 (최근 30일)
GUIBuilder
GUIBuilder 2011년 4월 27일
I need to start a timer and then block the MATLAB command line. In the background when a certain callback executes, I need to restart the timer and also block the MATLAB
I tried, but the code below does not work:
x=timer('Name','maxtimeBetweenEvents','StartDelay',20,'Timerfcn','a=1');
start(y);
start(x);
waitfor(x);
delete(x);
function restartTimerBetweenEvents
eventTimer=timerfind('Name','maxtimeBetweenEvents');
stop(eventTimer);
start(eventTimer);
waitfor(eventTimer);
end

답변 (1개)

Sarah Wait Zaranek
Sarah Wait Zaranek 2011년 4월 28일

I am not exactly sure what you want - but I think this is close.

1. Creating a timer that blocks the MATLAB command line for a certain time.

%% Create a timer
t = timer('Name','maxtimeBetweenEvents','StartDelay',30,'TimerFcn',@(x,y)disp('Hello World!'),'Tag','Waiting');
%% Start a timer
start(t)
%% Start your waiting 
wait(t)
disp('The wait is over!')

2. To restart the timer.

start(t)
wait(t)
disp('The wait is over!')

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by