Finding unique values from arrays of different sizes

56 Ansichten (letzte 30 Tage)
waqas
waqas am 8 Mär. 2019
Bearbeitet: Stephan am 8 Mär. 2019
I am trying to find the unique values from 4 different arrays but the sizes are different i.e., for 2 arrays size is c1=c2= [42,1] and for other two, it is c3=c4=[40,1].
For one part of the code where these dimensions were same I used
hElem = unique([c1 c2 c3 c4]);
But for the discussed case it is not possible since I am unable to make the matrix. Any suggestions?

Akzeptierte Antwort

Stephan
Stephan am 8 Mär. 2019
Bearbeitet: Stephan am 8 Mär. 2019
Hi,
transpose them:
A = [1; 2; 3];
B = [3; 4; 5];
C = [5; 6];
D = [8; 9];
% works_not = unique([A B C D])
works = unique([A' B' C' D'])
or arrange them like this:
also_works = unique([A; B; C; D])
Best regards
Stephan

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by