multiplication of certain values using logical array
Afficher commentaires plus anciens
Hi all,
I have a matrix from which I have derived a logical array. What I'd like to do is multiply true values in the original matrix by -1. I can change these values to a constant value but I can't figure out how to multiply the existing value.
I should add that I'm after a vectorisation rather than loops to quicken my script.
thanks in advance,
Rachel
Réponse acceptée
Plus de réponses (2)
Rachel
le 2 Fév 2012
0 votes
Amit Davidi
le 2 Fév 2012
Of course, it'll change only the values where the logical array is true. Note, however, that the command
B = -A(fltr);
would not give you what you want! This will result in a column vector of the changed values.
Catégories
En savoir plus sur Multidimensional Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!