Eliminate a row where a column has repeated values
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi I have the following matrix
eliti =
Columns 1 through 8
0 0 1.0000 0 0 0 0 0
0 0 1.0000 0 0 0 0 0
0 1.0000 0 1.0000 1.0000 0 0 0
Columns 9 through 16
0 0 0 0 0 1.0000 1.0000 0
1.0000 1.0000 0 0 0 0 1.0000 0
0 0 0 0 0 0 1.0000 0
Columns 17 through 21
-24.0000 38.0000 10.0751 0.0413 0.2388
-52.0000 26.0000 11.1629 0.0458 0.6012
-24.0000 38.0000 10.0751 0.0413 0.3106
And I need to eliminate where there a repeated values in the 18th column so it will be like this eliti =
Columns 1 through 8
0 0 1.0000 0 0 0 0 0
0 1.0000 0 1.0000 1.0000 0 0 0
Columns 9 through 16
1.0000 1.0000 0 0 0 0 1.0000 0
0 0 0 0 0 0 1.0000 0
Columns 17 through 21
-24.0000 38.0000 10.0751 0.0413 0.2388
-52.0000 26.0000 11.1629 0.0458 0.6012
댓글 수: 0
채택된 답변
추가 답변 (1개)
Chad Greene
2016년 6월 3일
You can use the indices returned by unique to get the rows corresponding to unique values in column 18:
M = randi(5,[3 21])
[~,ia] = unique(M(:,18))
M_new = M(ia,:);
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!