Finding unique values from arrays of different sizes

66 次查看(过去 30 天)
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?

采纳的回答

Stephan
Stephan 2019-3-8
编辑:Stephan 2019-3-8
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by