So I have matrix A that is 3x5 and a matrix B with random values and same dimensions as matrix A.
I want to find the elements in matrix B where the generated random number is lower than 0.6 and then change the coresponding elements in matrix A from 0 to 1 or from 1 to 0. Is there a way to do this without going into a for loop?
A=[0 0 0 1 0;1 1 1 0 0;1 0 1 1 0]
A(B<0.6 & A==0)=1
A(B<0.6 & A==1)=0
When I run this code it does what it's supposed to but the last line takes the newly-formed ones and then turnes them into zeros as well (which is not what i want).