how to compare 2 or more cell arrays?
Mostra commenti meno recenti
Hi, i have 2 cells(cell1 and cell2) of size 628*1 and 244*1 respectively, and i want to compare the elements of cell 1 with the elements of cell 2 and return only the matched ones from cell1 and delete the rests
cell1{k,1}={' *tcaa-a6-2677*';'tcca-a6-2681';' *tcca-aa-3566*';............};
%
cell2{k,1}={'TCCA-A6-2671-11A-01R-1758-07';' *TCCA-A6-2677*-11A-01R-0826-07';'TCCA-AA-3520-11A-01R-0721-07'; 'TCCA-AA-3528-11A-01R-1758-07'; *TCCA-AA-3566*-01A-01R-0125-07';.................}
Hints: i tried strncmpi and length, but because of size issue i get confused about which Command statement is better in my case.
Risposta accettata
Più risposte (1)
cell1 = {'apple' 'boy' 'cat' 'dog' 'elephant'} ;
cell2 = {'apple' 'ball' 'cut' 'dog' 'egg' 'frog' 'gun'} ;
iwant = intersect(cell1,cell2) ;
9 Commenti
chocho
il 9 Mar 2017
KSSV
il 9 Mar 2017
You got empty cell with the above example? Or with your data?
chocho
il 9 Mar 2017
Well it is because of different letter cases and text completely different. You see from cell1 you got tcaa-a6-2677 and cell2 you got TCCA-A6-2671-11A-01R-1758-07 only a part is in match. You have all strings like this or there would be an exact strings?
chocho
il 9 Mar 2017
Modificato: per isakson
il 10 Mar 2017
KSSV
il 9 Mar 2017
Are you okay if a part matches? I mean tcaa-a6-2677 and TCCA-A6-2671-11A-01R-1758-07 are same?
chocho
il 9 Mar 2017
chocho
il 9 Mar 2017
chocho
il 9 Mar 2017
Modificato: per isakson
il 10 Mar 2017
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!