String matrix compare to get common in rows
Show older comments
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
Accepted Answer
More Answers (1)
Geoff Hayes
on 27 Jun 2019
>> ismember(A1,A2)
ans =
1 0
0 0
5 Comments
Touts Touts
on 27 Jun 2019
Geoff Hayes
on 27 Jun 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
on 27 Jun 2019
- what happens if 'AA' occurs on different rows?
- what happens if 'AA' occurs multiple times within one matrix?
Touts Touts
on 28 Jun 2019
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!