Deleting Rows in a matrix

4 visualizzazioni (ultimi 30 giorni)
A
A il 13 Mar 2021
Commentato: A il 16 Mar 2021
I have a matrix:
A=[1 2 3;
5 6 7;
9 3 5;
9 5 2;
0 6 2;
7 3 6;
3 5 9;
0 2 4];
And another matrix
P=[1 2 3;
9 3 5;
9 5 2;
0 2 4;
7 3 6];
How can I delete the rows in A that have same elements in P?
For example:
A=[5 6 7;
9 5 2;
0 6 2;
3 5 9];
So the same rows in P are deleted in A

Risposta accettata

Walter Roberson
Walter Roberson il 13 Mar 2021
A=[1 2 3;
5 6 7;
9 3 5;
9 5 2;
0 6 2;
7 3 6;
3 5 9;
0 2 4];
P=[1 2 3;
9 3 5;
9 5 2;
0 2 4;
7 3 6];
setdiff(A, P, 'rows', 'stable')
ans = 3×3
5 6 7 0 6 2 3 5 9

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices 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