comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function out = strcellfind(strdb, str, findAll)
2 % out = strcellfind(strdb, str)
3 %
4 % finds a string within an cell array of strings
5 % only outputs the first occurence, unless
6 % findAll is set to true
7 %
8 % strcellfind is NOT CASE sensitive
9
10 if nargin < 3
11 findAll = 0;
12 end
13
14 out = [];
15 for i = 1:length(strdb)
16 if strcmpi( lower(char(strdb{i})), lower(char(str))) == 1;
17 if ~findAll
18 out = i;
19 return;
20 else
21 out(end+1) = i;
22 end
23 end
24 end
25 % ---
26 % NOTE: Bad backwards compability
27 % ---
28 % if isempty(out)
29 % out = -1;
30 % end