MATLAB: Random number generator help

MATLABrandom number generator

what is the implication of ">0.2" and "*2-1" in (rand(N)>0.2)*2-1 ?

Best Answer

Suppose N=[0.11 0.23 0.25 0.05 0.5]
N>=0.2
The result is
0 1 1 0 1
If you multiply the result by 2 you will get
0 2 2 0 2
and so on