%% Stop Timer
% Create a timer object that generates 100 random numbers and executes one million times. Define a StopFcn callback that displays the message 'Timer has stopped.' Start the timer and verify the timer is running

t = timer('TimerFcn','rand(100,1);',...
    'ExecutionMode','fixedSpacing','TasksToExecute',1e6,...
    'StopFcn','disp(''Timer has stopped.'')');
start(t)
t.Running

%
% Manually stop the timer and verify it is no longer running. Delete the timer.

stop(t)
t.Running
delete(t)

% Copyright 2015 The MathWorks, Inc.