wolffd@0: function ndx = strmatch_substr(str, strs) wolffd@0: % STRMATCH_SUBSTR Like strmatch, except str can match any part of strs{i}, not just prefix. wolffd@0: % ndx = strmatch_substr(str, strs) wolffd@0: % wolffd@0: % Example: wolffd@0: % i = strmatch('max', {'max','minimax','maximum'}) wolffd@0: % returns i = [1; 3] since only 1 and 3 begin with max, but wolffd@0: % i = strmatch_substr('max', {'max','minimax','maximum'}) wolffd@0: % returns i = [1;2;3]; wolffd@0: % wolffd@0: % If str is also a cell array, it is like calling strmatch_substr several times wolffd@0: % and concatenating the results. wolffd@0: % Example: wolffd@0: % wolffd@0: % i = strmatch_substr({'foo', 'dog'}, {'foo', 'hoofoo', 'dog'}) wolffd@0: % returns i = [1;2;3] wolffd@0: wolffd@0: ndx = []; wolffd@0: if ~iscell(str), str = {str}; end wolffd@0: for j=1:length(str) wolffd@0: for i=1:length(strs) wolffd@0: %ind = strfind(strs{i}, str{j}); % not supported in 6.0 wolffd@0: ind = findstr(strs{i}, str{j}); wolffd@0: if ~isempty(ind) wolffd@0: ndx = [ndx; i]; wolffd@0: end wolffd@0: end wolffd@0: end