Replace an element in a matrix if it's a member of an array with zero
1 回表示 (過去 30 日間)
古いコメントを表示
採用された回答
michio
2016 年 12 月 14 日
ismember function can do the job. As it's stated in the doc page, "Lia = ismember(A,B) returns an array containing logical 1 (true) where the data in A is found in B."
Please try the following do see what it does.
b = magic(4)
a = [1,2,3,4];
I = ismember(b,a)
b(I) = 0
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!