Find in cell array

4 views (last 30 days)
hamed
hamed on 25 Sep 2017
Commented: hamed on 25 Sep 2017
Hi all
I have 2 cell arrays.
one of them is my EEG bad channels and another is all EEG channels.
I want to find row numbers of the bad channels in my all EEG channels. For example, I have c4 in my bad channels and c4 in all channels file is 35.
and Fp2 is 3 in all channels. I want to do it by code. I've tried with:
idx = find(ismember(A,B))
but it works just when I put B in '' for instance:
idx = find(ismember(all_channels,'C4')) %ismember is case sensitive
I've attached my .mat files.
would you please help me.
Hamed

Accepted Answer

KL
KL on 25 Sep 2017
Edited: KL on 25 Sep 2017
ind = cellfun(@find,cellfun(@(c) strcmp(all_channels,c),bad_channels,'uni',0))
  3 Comments
KL
KL on 25 Sep 2017
See my edited answer. This should do what you want.
hamed
hamed on 25 Sep 2017
yes, it works perfectly
Thanks a lot for your help

Sign in to comment.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!