wolffd@0: function [idx, strpos] = substrcellfind(strdb, str, findAll) wolffd@0: % [idx, strpos] = substrcellfind(strdb, str) wolffd@0: % wolffd@0: % finds a string within an cell array of strings wolffd@0: % only outputs the first occurence, unless wolffd@0: % findAll is set to true wolffd@0: % wolffd@0: % substrcellfind is NOT CASE sensitive wolffd@0: wolffd@0: if nargin < 3 wolffd@0: findAll = 0; wolffd@0: end wolffd@0: wolffd@0: idx = []; wolffd@0: strpos = []; wolffd@0: for i = 1:length(strdb) wolffd@0: wolffd@0: % search string in cell db wolffd@0: tpos = strfind(lower(char(strdb{i})), lower(str)); wolffd@0: wolffd@0: if ~isempty(tpos) wolffd@0: wolffd@0: strpos(end+1) = tpos; wolffd@0: wolffd@0: if ~findAll wolffd@0: wolffd@0: idx = i; wolffd@0: return; wolffd@0: else wolffd@0: idx(end+1) = i; wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: % if isempty(idx) wolffd@0: % idx = -1; wolffd@0: % end