How to find unique matrix from given array and corresponding indexes?
2 ビュー (過去 30 日間)
古いコメントを表示
I have
A
A(:,:,1) =
Columns 1 through 2
20 20.05
20.05 20
19.95 20
Column 3
19.95
19.95
20.05
A(:,:,2) =
Columns 1 through 2
20 20.05
20.05 20
19.95 20
Column 3
19.95
19.95
20.05
A(:,:,3) =
Columns 1 through 2
20.05 20
20.05 20
19.95 20
Column 3
19.95
19.95
20.05
>> unique(A)
ans =
19.95
20
20.05
But i need to find out unique matrices and corresponding indexes
B
B(:,:,1) =
Columns 1 through 2
20 20.05
20.05 20
19.95 20
Column 3
19.95
19.95
20.05
B(:,:,2) =
Columns 1 through 2
20.05 20
20.05 20
19.95 20
Column 3
19.95
19.95
20.05
>> index = [1,3]
index =
1 3
In this format B and index.
0 件のコメント
採用された回答
Chunru
2021 年 8 月 28 日
A(:,:,1) = [ 20 20.05 19.95
20.05 20 19.95
19.95 20 20.05];
A(:,:,2) = [ 20 20.05 19.95
20.05 20 19.95
19.95 20 20.05];
A(:,:,3) = [ 20.05 20 19.95
20.05 20 19.95
19.95 20 20.05];
% Reshape the matrix and find unique along each row
[uA, iA] = unique(reshape(A, [], size(A,3))', 'rows');
B = reshape(uA', size(A,1), size(A,2), [])
iA'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!