Finding unique values from arrays of different sizes

66 ビュー (過去 30 日間)
waqas
waqas 2019 年 3 月 8 日
編集済み: Stephan 2019 年 3 月 8 日
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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by