Date: Mar 15, 2013 12:52 PM
Author: Bruno Luong
Subject: Re: Searchnig for a string in a array

% The shortest is not always the fastest

A(1:2:1e6) = {1};
A(2:2:1e6) = {'Hello World is here'};

tic;
loc = find( cellfun(@(x) ischar(x) && ~isempty(regexp(x, 'is', 'ignorecase')), A) );
toc % Elapsed time is 7.959571 seconds.

tic
b = cellfun('isclass',A,'char');
i = find(b);
loc = i(~cellfun('isempty',strfind(lower(A(b)),'is')));
toc % 0.636606 seconds.

% Bruno