How can I remove redundant rows in matrix with respect two just first three columns?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
A= [1,1,4,5,6;
2,7,4,5,7;
1,1,4,2,3;]
I want the matrix to remove redundant elements based on just first three columns, so my result should be
A = [1,1,4,5,6;
2,7,4,5,7]
I tried
unique(A,'rows')
But it works for all the columns. How do I proceed with it?
0 Kommentare
Antworten (1)
Walter Roberson
am 22 Okt. 2016
[~, ia] = unique(A(:,1:3), 'rows', 'stable');
B = A(ia,:);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!