comparing categorical arrays in terms of content
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have two categorical arrays A and B. I want to idenitfy
- common elements of A and B
- elements that are in one of them but not in both of them
3 Commenti
KALYAN ACHARJYA
il 24 Gen 2021
@Matt Gaidica provided the suffcient information, just use ismember, it is simple. Please refer MATLAB doc.
Risposta accettata
Adam Danz
il 24 Gen 2021
ismember alone can answer the first point (common elements of A and B) but not the 2nd since it only tests whether elements of A are in B but not whether elements of B are in A. For example,
A = categorical({'a' 'b' 'c' 'e'}');
B = categorical({'a' 'b' 'c' 'd'}');
[LIA,LOCB] = ismember(A,B)
setxor can show their differences.
[C,~,~] = setxor(A,B)
3 Commenti
Adam Danz
il 24 Gen 2021
Check out the first sentence of the documentation for each function. If that's not clear I'd be happy to explain.
You could also experiment to see what the differences are .
A = categorical({'a' 'b' 'c' 'e'}');
B = categorical({'a' 'b' 'c' 'd'}');
setdiff(A,B)
setdiff(B,A)
setxor(A,B)
setxor(B,A)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!