Changing values in 2D array using logical operators

2 vues (au cours des 30 derniers jours)
Bob
Bob le 18 Juil 2012
I'm sure I've solved this before, but it's befuddled me today.
I have a 2D array and I want to subselect some values and set them to nan:
aa=rand(10,10);
ab(aa<0.5)=nan;
ab is now a 1x100 row vector - how can I perform the operation but maintain the 2D array?

Réponse acceptée

Sebastian Holmqvist
Sebastian Holmqvist le 18 Juil 2012
aa = rand(10, 10);
aa(aa < 0.5) = NaN;

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by