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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Guillaume
Guillaume il 12 Lug 2019
Two of many possible ways:
yourmatrix(diff(yourmatrix(:, [1 2]), [], 2) == 0 , :) = [];
yourmatrix(yourmatrix(:, 1) == yourmatrix(:, 2), :) = [];

Più risposte (0)

Categorie

Scopri di più su Portfolio Optimization and Asset Allocation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by