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!