Mercurial > hg > camir-aes2014
comparison core/tools/substrcellfind.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 [idx, strpos] = substrcellfind(strdb, str, findAll) | |
2 % [idx, strpos] = substrcellfind(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 % substrcellfind is NOT CASE sensitive | |
9 | |
10 if nargin < 3 | |
11 findAll = 0; | |
12 end | |
13 | |
14 idx = []; | |
15 strpos = []; | |
16 for i = 1:length(strdb) | |
17 | |
18 % search string in cell db | |
19 tpos = strfind(lower(char(strdb{i})), lower(str)); | |
20 | |
21 if ~isempty(tpos) | |
22 | |
23 strpos(end+1) = tpos; | |
24 | |
25 if ~findAll | |
26 | |
27 idx = i; | |
28 return; | |
29 else | |
30 idx(end+1) = i; | |
31 end | |
32 end | |
33 end | |
34 | |
35 % if isempty(idx) | |
36 % idx = -1; | |
37 % end |