Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: picking random numbers  between a certain range
Date: Thu, 18 Feb 2010 16:27:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 15
Message-ID: <hljpon$sjd$1@fred.mathworks.com>
References: <hljnjv$7kr$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1266510423 29293 172.30.248.35 (18 Feb 2010 16:27:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Feb 2010 16:27:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:609343

"Kenzo Mendoza" <kenzo_mendoza@knights.ucf.edu> wrote in message <hljnjv$7kr$1@fred.mathworks.com>...
> Hi
> I would like to initialize a vector with random numbers between -2 and 2
> 
> would it be something like x=rand(1,10) *2?
> 
> Any response will be greatly appreciated 

Maybe it is more of a statistics question.

If U is uniformly distributed over [0,1), then 4*U-2 will be uniformly distributed over [-2,2).

Then, x = 4*rand(1,10)-2; would do it for you.

Best.