Replace the value of one column conditional on another column
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Library Development in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!