Finding unique values from arrays of different sizes

66 visualizaciones (últimos 30 días)
waqas
waqas el 8 de Mzo. de 2019
Editada: Stephan el 8 de Mzo. de 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?

Respuesta aceptada

Stephan
Stephan el 8 de Mzo. de 2019
Editada: Stephan el 8 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by