From: bluesaturn[at]kellnerweg.de on
Hi there.
I have 1x7 cell array with the contents:

'.' '..' 'H66000.526' 'H66001.526' 'H66002.526' 'H66003.526' 'H66004.526'

How can I combine cellfun and strfind to find '001.' in the other strings, please?

Thank you.
From: Walter Roberson on
bluesaturn[at]kellnerweg.de wrote:

> I have 1x7 cell array with the contents:
>
> '.' '..' 'H66000.526' 'H66001.526' 'H66002.526' 'H66003.526' 'H66004.526'
>
> How can I combine cellfun and strfind to find '001.' in the other strings, please?

cellfun(@(IDX) ~isempty(IDX), strfind(TheCell, '.001'))

This will return a logical vector, one per row, true indicating that the
row matched. Is that what you were seeking, or were you looking for
the indices?

Positions = zeros(length(TheCell),1);
T = strfind(TheCell, '.001);
E = cellfun(@isempty, T);
Positions(~E) = cellfun(@(IDX) IDX(1), T(~E));

This will create Positions as 0 for rows that do not contain the string
and as the index of the first occurance of 001. for the rows that do.
From: us on
"bluesaturn[at]kellnerweg.de" <bluesaturn(a)kellnerweg.de> wrote in message <842533083.265829.1275487979925.JavaMail.root(a)gallium.mathforum.org>...
> Hi there.
> I have 1x7 cell array with the contents:
>
> '.' '..' 'H66000.526' 'H66001.526' 'H66002.526' 'H66003.526' 'H66004.526'
>
> How can I combine cellfun and strfind to find '001.' in the other strings, please?
>
> Thank you.

one of the many solutions

c={'.','..','ab001','ab002','ac001'};
ix=~cellfun(@isempty,regexp(c,'001'))
% ix = 0 0 1 0 1

us
From: bluesaturn[at]kellnerweg.de on
Hello!
Yes, I was looking if there is a file containing 001. in the name. So my function gave me back the position and I could collect the name.
With the help of this group I am using now

file_position1=find(~cellfun('isempty', strfind(files_in_folder_names,'000.')));

and by knowing the position I will get the full name later.
Thank you as well for your suggestions.