How to remove common row elements from matrix

조회 수: 3 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2020년 7월 8일
댓글: Poulomi Ganguli 2020년 7월 8일
Hello:
I have large number of arrays with mix of NaNs & numbers, for example:
NaN NaN NaN NaN NaN NaN 1973 1 15 1973 4 14 90
1979 11 3 12 22 10 1979 11 25 1980 1 5 64
1980 4 15 1 2 1 1980 4 17 1980 5 17 33
2017 10 23 5 7 2 2017 10 30 2018 6 10 231
NaN NaN NaN NaN NaN NaN 2018 1 23 2018 7 21 180
NaN NaN NaN NaN NaN NaN 2018 6 14 2018 7 21 38
2018 10 2 17 22 5 2018 10 24 2018 12 31 91
I need to identify the row-wise common datetime elements, for example, rows 5 and 6 here, where Year-month-day of cols. 10-12 are common. My desired output would be identify such common rows from each iteration and delete that particular row. For example, desired output here would be:
Nan NaN NaN NaN NaN NaN 1973 1 15 1973 4 14 90
1979 11 3 12 22 10 1979 11 25 1980 1 5 64
1980 4 15 1 2 1 1980 4 17 1980 5 17 33
2017 10 23 5 7 2 2017 10 30 2018 6 10 231
NaN NaN NaN NaN NaN NaN 2018 1 23 2018 7 21 180
2018 10 2 17 22 5 2018 10 24 2018 12 31 91
Any suggestions how to automate this operation?

채택된 답변

dpb
dpb 2020년 7월 8일
[~,ia]=unique(A(:,10:12),'rows');
O=A(ia,:);

추가 답변 (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