Execute command if timer runs out
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponse acceptée
Josh
le 11 Mai 2019
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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!