Deleting Rows in a matrix

4 vues (au cours des 30 derniers jours)
A
A le 13 Mar 2021
Commenté : A le 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

Réponse acceptée

Walter Roberson
Walter Roberson le 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
  1 commentaire
A
A le 16 Mar 2021
Thank you so much!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by