how to find a string within a cell array

I have a cell array like this:
'10 Hz: Time_abs'
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
<1x2 cell>
'10 Hz: Time_abs'
<1x2 cell>
<1x2 cell>
<1x2 cell>
at first I need to find in which rows there is '10 Hz: Time_abs' and then delete the corresponding row. I can not use strcmp or isstr because the other rows are cell and are not comparable with a string.
can anybody help me with that,I really appreciate that.
best, Navid

1 件のコメント

Geoff Hayes
Geoff Hayes 2014 年 4 月 27 日
Why not iterate over each element within the cell array and copy those that aren't strings (that match '10 Hz: Time_abs') to another cell array?

サインインしてコメントする。

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 27 日

1 投票

p='10 Hz: Time_abs'
A={'10 Hz: Time_abs';{'yytt' 'rr'};{'yyt2t' 'rr1'}}
A(cellfun(@(x) any(strcmp(x,p)),A))=[]

3 件のコメント

Navid
Navid 2014 年 4 月 27 日
Many thanks,it's working,is it possible to have the index of these rows?
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 27 日
p='10 Hz: Time_abs'
A={'10 Hz: Time_abs';{'yytt' 'rr'};{'yyt2t' 'rr1'}}
idx=find(cellfun(@(x) any(strcmp(x,p)),A))
Navid
Navid 2014 年 4 月 27 日
I really appreciate your help,thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2014 年 4 月 27 日

コメント済み:

2014 年 4 月 27 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by