Replace the value of one column conditional on another column
Afficher commentaires plus anciens
I have a problem to generate a vector with varying number of blocks. Suppose A=[0 1;0 1;0 2;0 2;0 2;0 3;0 3;0 3], the last column of A is the index for groups. I want to replace the value of the first column of A for different groups. For example, I want to replace the first few elements of A(:,1) with [0.5;0.8] if the second column equals 1. Replace the block elements of A(:,1) with [0.4, 0.6, 0.8] if the second column equals 2, etc., Is there any easy way to do that? Thanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Library Development 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!