Deleting rows of a matrix based on values from another matrix
26 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Johan
2022-7-8
A = randi(5,5,3)
B = randi(5,2,1)
% Find all the row where col 1 to 2 of A have a value in B
mask = any(ismember(A(:,1:2),B),2)
A(mask,:) = [] % delete the rows of A according to the mask
0 个评论
更多回答(1 个)
Kritarth Sinha
2022-7-8
编辑:Kritarth Sinha
2022-7-8
Hello Hari,
You can simply use nested loops and for each value in column 1 or 2,you can check that is present in matrix B and do it accordingly.
Hope this will help.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!