logical operation on a column within a matrix
Afficher commentaires plus anciens
I have the m-by-n matrix POS
I want to focus on a single column and perform an element-wise logical operation. For instance, turning all zero's to ones:
POS(POS(:,2)==0)=1;
However, this does nothing. On the other hand, this works on the whole matrix:
POS(POS==0)=1;
But, obviously, I just want to perform this operation on column 2. What am I missing? I do not want another line of code since speed is very important here.
Even more confusing, the following works on the first column, but not on the second:
POS(POS(:,1)==1)=2; % works
POS(POS(:,2)==1)=2; % not working
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Multicore Processor Targets dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!