Deleting Rows in a matrix

1 次查看(过去 30 天)
A
A 2021-3-13
评论: A 2021-3-16
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

采纳的回答

Walter Roberson
Walter Roberson 2021-3-13
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by