How to compare cell A and cell B

Hello, I need to pick up one element from cell array A and find it in cell array B so the output should be T=0/1 contains/doesn't contain element B and F which is coordinate of this element in cell array B. The part I have problem with is, that i just can't compare these 2 cells (d==g in code). I'm sorry for my terminology I'm just a beginer.
load A.mat
load B.mat
d=A(10,1)
e=length(B');
T=0
for i=1:e
g=b(i:1)
if d==g
T=1
F=i
break
end
end
Thanks for help.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 1 Apr 2013
Edited: Azzi Abdelmalek on 1 Apr 2013
out=cellfun(@(x) ismember(x,cell2mat(B)),A,'un',0)
F=cellfun(@(x) find(ismember(cell2mat(B),x)),A,'un',0)

Categories

Tags

Asked:

on 1 Apr 2013

Community Treasure Hunt

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

Start Hunting!