필터 지우기
필터 지우기

identify duplicate entries of matrix and delete

조회 수: 2 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2017년 10월 13일
댓글: Star Strider 2017년 10월 14일
Hello,
I have an array as follows. I need to identify duplicate row values from column 1 to 5 and delete the row with negative 7th column element and keep the other row. For example, here row values 5 and 6:
1973 4 1 13 1,34 1,31 0,95 0,35
1973 4 2 2 1,17 1,14 0,85 0,29
1973 4 2 8 -0,5 -0,53 -0,81 0,28
1973 4 2 15 1,54 1,51 1,03 0,48
1973 4 2 18 1,82 1,79 1,03 0,76
1973 4 2 18 1,82 1,79 -0,54 2,33
1973 4 3 3 2,24 2,21 1,02 1,19
1973 4 3 15 1,73 1,70 1,15 0,54
The resulting matrix
1973 4 1 13 1,34 1,31 0,95 0,35
1973 4 2 2 1,17 1,14 0,85 0,29
1973 4 2 8 -0,5 -0,53 -0,81 0,28
1973 4 2 15 1,54 1,51 1,03 0,48
1973 4 2 18 1,82 1,79 1,03 0,76
1973 4 3 3 2,24 2,21 1,02 1,19
1973 4 3 15 1,73 1,70 1,15 0,54
Any help?

채택된 답변

Star Strider
Star Strider 2017년 10월 13일
Assigning your matrix to variable ‘M’, this should do what you want:
[~,idx] = unique(M(:,1:5), 'rows', 'stable');
Result = M(idx,:);
  댓글 수: 4
Poulomi Ganguli
Poulomi Ganguli 2017년 10월 14일
Thanks a bunch!!
Star Strider
Star Strider 2017년 10월 14일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by