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.

isalogical(number)
function response = isalogical(number)
% ISALOGICAL tests for if it can be used in an if statement or not.
% Deliberately not designed with recursion for cell arrays since these are
% not logical.

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

% if its empty, it can't be used
if isempty(number)
    % not valid
    response = false;
    
elseif isnumeric(number)
    % checks the number some more
    response = isreal(number) & ~isnan(number) & isfinite(number);

elseif ischar(number) || islogical(number)
    % this is OK too
    response = true(size(number));
    
else
    % not defined for anything else
    response = false(size(number));
end

Contact us