MATLAB: How to stop timer function at a specified time

MATLABstartat image acquisition pausetimer

Hello..
I have used a timer function to capture image files continuously at a fixed rate automatically, at a specified time. I used startat function to do this and it's working, however, my problem is that, I can't stop it at a specified time I want. Instead I use pause. However, once I paused the program, the whole program halts and it never execute the next functions.
Can anyone help me?
Here's some part of my code:
dstart={'07:30' '07:32' '07:34' '12:00' '13:30' '15:00' '18:00' '19:30'};
dfinish={'07:31' '07:33' '07:35' '13:25' '07:31' '16:25' '09:01' '20:55'};
%here i used the captureimage function to capture image using imaq toolbox..
t1=timer('TimerFcn', 'captureimage', 'ExecutionMode', 'FixedRate');
tp1=timer('TimerFcn', 'pause'); %I can't stop the timer fcn that's why i use pause
%the capture starts exactly at 07:30AM continuously with 7second interval
startat(t1, dstart(1,1));
%here, the program pauses when it is exactly 07:31AM
startat(tp1, dfinish(1,1));
How can i stop the timer function without using pause, because instead of pausing the timer function, the whole program pauses.
I will greatly appreciate your help.
Thank you.

Best Answer

Kent, Why not build into the callback a comparison of the current time (help NOW) with the desired stop time? Then, if current time >= desiredStopTime, then issue a STOP command. Cheers, Brett