How to remove particular rows from a matrix?
1 次查看(过去 30 天)
显示 更早的评论
I need to remove particular row from a matrix A but only once, example:
A=[1 2 3 4; 1 2 3 4; 1 2 3 4; 1 1 1 1; 7 8 9 0]; y=[1 2 3 4; 1 1 1 1]; %the rows [1 2 3 4] in y occurs 3 times in A, I want to remove it only once
so setdiff(A,y, 'rows'); wont work.
But I need something general that works for arbitrary A and y
Thank you :)
0 个评论
采纳的回答
Walter Roberson
2020-2-22
编辑:Walter Roberson
2020-2-22
[found, idx] = ismember(y, A, 'rows');
A(idx(found). :) = []; %delete one copy of the found ones
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!