How to replace elements using logical operations?

1 次查看(过去 30 天)
Let A = [2 13 1; 2 5 16; 11 9 8]
What I want to do is for element that are less than 6, replace the element with 0.
How do I do this using for/if operation ?
Thanks in advance.

采纳的回答

Friedrich
Friedrich 2014-5-19
Hi,
try
>> A(reshape(A < 6,[],1)) = 0

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by