How to remove all the rows if first two columns has same number?

조회 수: 1 (최근 30일)
Kurni Eswar
Kurni Eswar 2019년 7월 12일
답변: Guillaume 2019년 7월 12일
I have matrix like this. I wants to remove the all the rows which contain same numbers in first two columns
1 1 1 200 2
1 2 2 200 2
1 3 3 200 2
1 4 4 200 2
2 1 1 200 2
2 2 2 200 2
2 3 3 200 2
2 4 4 200 2
3 1 1 200 2
3 2 2 200 2
3 3 3 200 2
3 4 4 200 2
4 1 1 200 2
4 2 2 200 2
4 3 3 200 2
4 4 4 200 2
for example
1 2 2 200 2
1 3 3 200 2
1 4 4 200 2
2 1 1 200 2
2 3 3 200 2
2 4 4 200 2
3 1 1 200 2
3 2 2 200 2
3 4 4 200 2
4 1 1 200 2
4 2 2 200 2
4 3 3 200 2

채택된 답변

Guillaume
Guillaume 2019년 7월 12일
Two of many possible ways:
yourmatrix(diff(yourmatrix(:, [1 2]), [], 2) == 0 , :) = [];
yourmatrix(yourmatrix(:, 1) == yourmatrix(:, 2), :) = [];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by