Finding unique values from arrays of different sizes

65 views (last 30 days)
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?

Accepted Answer

Stephan
Stephan on 8 Mar 2019
Edited: Stephan on 8 Mar 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

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!