String matrix compare to get common in rows
Afficher commentaires plus anciens
Deal all, i have a problem to compare two string matrix :
A1 = {'AA', 'b' ; 'cc', 'ff'}
A2 = {'ee', 'AA' ; 'hhh', 'm'}
strcmp(A1,A2)
I get
A1 =
'AA' 'b'
'cc' 'ff'
A2 =
'ee' 'AA'
'hhh' 'm'
ans =
0 0
0 0
But i need to get
'AA' is common between A1 iand A2 in the row 1
Best regard
Réponse acceptée
Plus de réponses (1)
Geoff Hayes
le 27 Juin 2019
>> ismember(A1,A2)
ans =
1 0
0 0
5 commentaires
Touts Touts
le 27 Juin 2019
Geoff Hayes
le 27 Juin 2019
So if 'AA' is in the second row, do you expect to see
'AA' : 2
? What happens if 'AA' is in more than one row?
Touts Touts
le 27 Juin 2019
- what happens if 'AA' occurs on different rows?
- what happens if 'AA' occurs multiple times within one matrix?
Touts Touts
le 28 Juin 2019
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!