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.

ispositiveinteger(number)
function response = ispositiveinteger(number)
% ISPOSITIVEINTEGER tests for if it is a postive (non-zero) integer or not

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

% if its a cell array, recursively check it
if iscell(number)
    % try
    response = cellfun(@ispositiveinteger, number, 'UniformOutput', 'false');
    
elseif isstruct(number)
    % errors
    error('Not defined for structures.')
    
else
    % checks the number
    response = isainteger(number);

    % if it is an integer, check it some more (done this way to allow effective
    % short-circuiting)
    if any(response)
        % check
        response = response & number > 0;
    end
end

Contact us