The PAUSE statement in the timer's callback function will pause MATLAB execution completely. PAUSE will not stop the MATLAB execution if the PAUSE is outside the timer's TimerFcn callback.
To pause timer's execution,you can use timer's 'StartDelay' property. You can stop the timer at a certain point, set 'StartDelay' property of a timer, and then start the timer again. The timer's execution will start after 'StartDelay' amount of time elapses. Consider the following example:
function timer_test
t1 = timer('ExecutionMode','fixedRate','TimerFcn','disp(''Timer ONE is executing'')');
t2 = timer('ExecutionMode','fixedRate','TimerFcn','disp(''Timer TWO is executing'')');
start(t1)
start(t2)
pause(3)
stop(t1)
disp('Timer 1 is stopped. Its execution will start in 3 seconds')
set(t1,'StartDelay',3)
start(t1)
pause(5)
stop(t1)
stop(t2)
delete(t1)
delete(t2)
Best Answer