0

I want to find the overlap between this 2 cell arrays by comparing them row by row and get the overlapped rows:

ex1={'BRDT','TBP';'php','alm';'BRCA1','TP53'};  
ex2={'TBP','HIST1H2BH';'RB1','TK2';'php','alm'};
desire_output={'php','alm'}

I have tried this command and get <2x1 cell>array, but i want <1x2 cell>(whole row) :

 a=intersect(ex1,ex2,'stable');
Leander Moesinger
  • 2,449
  • 15
  • 28
F.caren
  • 85
  • 1
  • 9

1 Answers1

0

How about using ismember and picking the required row?

ex1={'BRDT','TBP';'php','alm';'BRCA1','TP53'};
ex2={'TBP','HIST1H2BH';'RB1','TK2';'php','alm'};
out = ismember(ex1,ex2) ;
iwant = ex1(all(out,2),:) ;
Siva Srinivas Kolukula
  • 1,251
  • 1
  • 7
  • 14