How to find unique matrix from given array and corresponding indexes?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Chunru
il 28 Ago 2021
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'
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!