Deleting rows of a matrix based on values from another matrix
27 ビュー (過去 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 で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!