See if my code to kill all timers works for you:
function StopTimer(handles)
try
fprintf('Entering StopTimer...\n');
listOfTimers = timerfindall
if isempty(listOfTimers)
fprintf('There are no timers to turn off. Leaving StopTimer().\n');
return;
end
handleToTimer = getappdata(handles.figMainWindow, 'timerObj');
stop(handleToTimer);
listOfTimers = timerfindall
if ~isempty(listOfTimers)
delete(listOfTimers(:));
end
fprintf('Left StopTimer and turned off all timers.\n');
catch ME
errorMessage = sprintf('Error in StopTimer().\nThe error reported by MATLAB is:\n\n%s', ME.message);
fprintf('%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
return;
Best Answer