Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

timerfcn(timerObject)
function timerfcn(timerObject)
% TIMERFCN runs the timer function early

% checks the number of arguments
error(nargchk(1, 1, nargin))

% checks the timer object
if ~istimer(timerObject)
    % complain
    error('Object is not a valid timer.')
end

% gets the timer function
timerFunction = timerObject.TimerFcn;

% checks its not empty
if isempty(timerFunction)
    % complain
    error('There is no timer function in this timer.')
end

% gets the size of the timer object (can't use numel as this is not defined
% for timers (MATLAB R14SP3)
timerSize = prod(size(timerObject));

% if there is only one timer...
if timerSize == 1
    % need to turn it into a cell array so it works with the next loop
    timerFunction = {timerFunction};
end

% runs it for each element
for m = 1:timerSize
    % runs the function
    try
        % tries
        feval(timerFunction{m}{1}, timerObject(m), [], timerFunction{m}{2:end})

    catch
        % displays a warning
        warning('timerFcn:run', 'Did not run timer function successfully.')
    end
end

Contact us