cellstrfind finds matching strings inside a cellstr array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: cellstrfind finds matching strings inside a cellstr array CALL: [position, sum, value] = ssm.cellstrfind(c,s,option) INPUTS: c - cell array of strings s - string to look for option - defines the output 'position' > positions where s was found in c 'sum' > number of matches 'value' > logical array telling if s{i}==c 'all' > gives all three outputs above OUTPUTS: position sum value as explained above, number of output depends on 'option field' ***** There are no parameters ***** VERSION: '$Id: $' HISTORY: 07-08-2008 TO DO : check ME in case of mixed symbolic and double %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % cellstrfind finds matching strings inside a cellstr array 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: cellstrfind finds matching strings inside a cellstr array 0005 % 0006 % CALL: [position, sum, value] = ssm.cellstrfind(c,s,option) 0007 % 0008 % INPUTS: 0009 % c - cell array of strings 0010 % s - string to look for 0011 % option - defines the output 0012 % 'position' > positions where s was found in c 0013 % 'sum' > number of matches 0014 % 'value' > logical array telling if s{i}==c 0015 % 'all' > gives all three outputs above 0016 % 0017 % OUTPUTS: 0018 % position 0019 % sum 0020 % value 0021 % as explained above, number of output depends on 'option field' 0022 % 0023 % ***** There are no parameters ***** 0024 % 0025 % VERSION: '$Id: $' 0026 % 0027 % 0028 % HISTORY: 0029 % 07-08-2008 0030 % 0031 % TO DO : 0032 % check ME in case of mixed symbolic and double 0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0034 function varargout = cellstrfind(c,s,option) 0035 value = strcmp(c,s); 0036 position = find(value); 0037 sum = length(position); 0038 if strcmp(option, 'sum') 0039 varargout = {sum}; 0040 elseif strcmp(option, 'value') 0041 varargout = {value}; 0042 elseif strcmp(option, 'position') 0043 varargout = {position}; 0044 elseif strcmp(option, 'all') 0045 varargout = {position, sum, value}; 0046 end 0047 end