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.

isnumber(number)
function response = isnumber(number)
% ISNUMBER checks that it is a non-empty, non-NaN, real, finite number.

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

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

    % if it is valid
    if response
        % test it some more
        response = ~isnan(number) & isfinite(number);

    else
        % return a response the same size as the input
        response = false(size(number));
    end
end
    

Contact us