1. ## matlab

how can I generate a discrete random number from 3 possible numbers in matlab. Ex I want to choose ( 0 or 1 or -1)

2. Hello,
Originally Posted by florezl
how can I generate a discrete random number from 3 possible numbers in matlab. Ex I want to choose ( 0 or 1 or -1)
Well, you could define u=rand() and then, [if u<1 [if u<2/3 [if u<1/3, x=-1] x=0] x=1].
(rand() gives a value between 0 and 1)