Matlab - Random vector

What's a quick way to create a vector of 10 pseudo-random numbers, each either +1 or -1 (with equal probability)?
(MATLAB 7.5.0 R2007b)

Thanks
LVL 25
InteractiveMindAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jmlonConnect With a Mentor Commented:
Here is a solution I have:

x=rand(10,1)<0.5; y=-1*~x+x

Open in new window

0
 
mish33Connect With a Mentor Commented:
x=(rand(10,1)<0.5)*2-1
0
 
InteractiveMindAuthor Commented:
Very clever, thanks =)
0
All Courses

From novice to tech pro — start learning today.