필터 지우기
필터 지우기

Execute command if timer runs out

조회 수: 1 (최근 30일)
Taylor Hearn
Taylor Hearn 2019년 5월 10일
댓글: Taylor Hearn 2019년 5월 14일
I am developing an App in the App Designer, and I would like to have a block of code run if a timer expires. So basically, if a button is pressed within a certain time window, code A runs, but if no button is pressed within that time window, code B runs. Any suggestions? Thanks in advance!

채택된 답변

Josh
Josh 2019년 5월 11일
A timer object might work:
% Define callback
callback = @(x,y)disp('hello world');
% Create timer; this will execute TimerFcn after the 10s StartDelay has elapsed
t = timer( ...
'ExecutionMode', 'singleShot', ...
'StartDelay', 10, ...
'TimerFcn', callback);
% Start timer
start(t);
  댓글 수: 1
Taylor Hearn
Taylor Hearn 2019년 5월 14일
This is perfect! Combined with an if statement in the callback function this should do exactly what I'm aiming for. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by