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.

strfindcell(cellStrings, string)
function response = strfindcell(cellStrings, string)
% STRFINDCELL works similarly to strfind, except allows a cell array of
% strings as a matching pattern (rather than the other way round)

% checks the number of inputs
error(nargchk(2, 2, nargin))

% checks the inputs
if ~iscellstr(cellStrings)
    % errors
    error('First argument must be a cell array of strings.')
    
elseif ~ischar(string) || size(string, 1) ~= 1
    % errors
    error('String must be a row vector of type char.')
end

% tries to find each string in the cell array within the string
response = cellfun((@(x) any(strfind(string, x))), cellStrings);

Contact us