I have two matrices A and B. I want to know how do I change the values of A with using indexes of B.

`A = 1 2 0 6 3B = 1 1 0 1 0`

Essentially I want to add 5 to an index of A where B==1 and keep the rest of A unchanged so I can have A be like this. I'd also prefer if someone could show me how I would do this with a while loop.

`A = 6 7 0 11 3`

## Best Answer