How to replace elements using logical operations?

1 vue (au cours des 30 derniers jours)
LeBron
LeBron le 19 Mai 2014
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.

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by