comparison core/tools/strcellfind.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
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})), 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