% STARTTIMER returns a started timer.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% description: STARTTIMER returns a started timer.%% call: t = startTimer(name, fcn, period)%% inputs: name - name of the timer% fcn - call back function of the timer% period - period of the timer%% outputs: t - new timer object.%% version: $Id: startTimer.m,v 1.3 2011/02/03 13:44:02 ingo Exp $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function t = startTimer(name, fcn, period) t = timerfind('name', name); if isempty(t) || (isa(t, 'timer') && ~isvalid(t)) t = timer(... 'TimerFcn', fcn, ... 'StartDelay', period, ... 'Period', period, ... 'ExecutionMode', 'fixedRate', ... 'Name', name); end % start the timer if ~strcmp(get(t,'Running'), 'on') start(t); endend