Mercurial > hg > camir-aes2014
annotate core/tools/strcellfind.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function out = strcellfind(strdb, str, findAll) |
wolffd@0 | 2 % out = strcellfind(strdb, str) |
wolffd@0 | 3 % |
wolffd@0 | 4 % finds a string within an cell array of strings |
wolffd@0 | 5 % only outputs the first occurence, unless |
wolffd@0 | 6 % findAll is set to true |
wolffd@0 | 7 % |
wolffd@0 | 8 % strcellfind is NOT CASE sensitive |
wolffd@0 | 9 |
wolffd@0 | 10 if nargin < 3 |
wolffd@0 | 11 findAll = 0; |
wolffd@0 | 12 end |
wolffd@0 | 13 |
wolffd@0 | 14 out = []; |
wolffd@0 | 15 for i = 1:length(strdb) |
wolffd@0 | 16 if strcmpi( lower(char(strdb{i})), lower(char(str))) == 1; |
wolffd@0 | 17 if ~findAll |
wolffd@0 | 18 out = i; |
wolffd@0 | 19 return; |
wolffd@0 | 20 else |
wolffd@0 | 21 out(end+1) = i; |
wolffd@0 | 22 end |
wolffd@0 | 23 end |
wolffd@0 | 24 end |
wolffd@0 | 25 % --- |
wolffd@0 | 26 % NOTE: Bad backwards compability |
wolffd@0 | 27 % --- |
wolffd@0 | 28 % if isempty(out) |
wolffd@0 | 29 % out = -1; |
wolffd@0 | 30 % end |