Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/strmatch_substr.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function ndx = strmatch_substr(str, strs) |
matthiasm@8 | 2 % STRMATCH_SUBSTR Like strmatch, except str can match any part of strs{i}, not just prefix. |
matthiasm@8 | 3 % ndx = strmatch_substr(str, strs) |
matthiasm@8 | 4 % |
matthiasm@8 | 5 % Example: |
matthiasm@8 | 6 % i = strmatch('max', {'max','minimax','maximum'}) |
matthiasm@8 | 7 % returns i = [1; 3] since only 1 and 3 begin with max, but |
matthiasm@8 | 8 % i = strmatch_substr('max', {'max','minimax','maximum'}) |
matthiasm@8 | 9 % returns i = [1;2;3]; |
matthiasm@8 | 10 % |
matthiasm@8 | 11 % If str is also a cell array, it is like calling strmatch_substr several times |
matthiasm@8 | 12 % and concatenating the results. |
matthiasm@8 | 13 % Example: |
matthiasm@8 | 14 % |
matthiasm@8 | 15 % i = strmatch_substr({'foo', 'dog'}, {'foo', 'hoofoo', 'dog'}) |
matthiasm@8 | 16 % returns i = [1;2;3] |
matthiasm@8 | 17 |
matthiasm@8 | 18 ndx = []; |
matthiasm@8 | 19 if ~iscell(str), str = {str}; end |
matthiasm@8 | 20 for j=1:length(str) |
matthiasm@8 | 21 for i=1:length(strs) |
matthiasm@8 | 22 %ind = strfind(strs{i}, str{j}); % not supported in 6.0 |
matthiasm@8 | 23 ind = findstr(strs{i}, str{j}); |
matthiasm@8 | 24 if ~isempty(ind) |
matthiasm@8 | 25 ndx = [ndx; i]; |
matthiasm@8 | 26 end |
matthiasm@8 | 27 end |
matthiasm@8 | 28 end |