# Compare 8 different matrices with different sizes and find the number of non-repeated elements

1 visualizzazione (ultimi 30 giorni)
Cladio Andrea il 22 Feb 2015
Modificato: Guillaume il 23 Feb 2015
Hello everyone, i have 8 matrices, those size change after each simulation. What i want is to check all the elements in those matrices and see how many different elements i have. lets say A= [1,2,3,4,5,6] ,, B [1,2,9,11,12] what i want is that 1,2,3,4,5,6,9,11,12 and as a result number of non repeated element numbers in that case, 9.. Can anyone help please?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Guillaume il 22 Feb 2015
Modificato: Guillaume il 23 Feb 2015
Your example is not very clear as for me the non-repeated elements would be [3 4 5 6 9 11 12], so only 7.
Anyway, if you only had two vectors, you'd use setxor to get the non-repeated elements. With more than two, one possible way:
A = [1 2 3 4 5 6];
B = [1 2 9 11 12 13 14]
C = [7 8 13 14];
allelements = [A(:); B(:); C(:)];
uniqueelements = unique(allelements);
nonrepeated = uniqueelements(histc(allelements, uniqueelements) == 1)
nonrepeatedcount = numel(nonrepeated)
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Cladio Andrea il 23 Feb 2015
Thank you, just perfect!!

Accedi per commentare.

### Categorie

Scopri di più su Power Converters 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!

Translated by