http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125
MATLAB Central Newsreader  picking random numbers between a certain range
Feed for thread: picking random numbers between a certain range
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 18 Feb 2010 15:50:23 +0000
picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718914
Kenzo Mendoza
Hi<br>
I would like to initialize a vector with random numbers between 2 and 2<br>
<br>
would it be something like x=rand(1,10) *2?<br>
<br>
Any response will be greatly appreciated

Thu, 18 Feb 2010 16:10:24 +0000
Re: picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718923
Jan Simon
Dear Kenzo!<br>
<br>
> I would like to initialize a vector with random numbers between 2 and 2<br>
> <br>
> would it be something like x=rand(1,10) *2?<br>
<br>
Why do you ask us and not Matlab? Do you have a Matlab instance for trying it?<br>
If not, you'd observe that your command creates number between 0 and 2.<br>
<br>
Good luck, Jan

Thu, 18 Feb 2010 16:10:24 +0000
Re: picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718925
Oleg Komarov
"Kenzo Mendoza" <kenzo_mendoza@knights.ucf.edu> wrote in message <hljnjv$7kr$1@fred.mathworks.com>...<br>
> Hi<br>
> I would like to initialize a vector with random numbers between 2 and 2<br>
> <br>
> would it be something like x=rand(1,10) *2?<br>
> <br>
> Any response will be greatly appreciated <br>
<br>
help rand<br>
<br>
Oleg

Thu, 18 Feb 2010 16:27:03 +0000
Re: picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718933
Sadik
"Kenzo Mendoza" <kenzo_mendoza@knights.ucf.edu> wrote in message <hljnjv$7kr$1@fred.mathworks.com>...<br>
> Hi<br>
> I would like to initialize a vector with random numbers between 2 and 2<br>
> <br>
> would it be something like x=rand(1,10) *2?<br>
> <br>
> Any response will be greatly appreciated <br>
<br>
Maybe it is more of a statistics question.<br>
<br>
If U is uniformly distributed over [0,1), then 4*U2 will be uniformly distributed over [2,2).<br>
<br>
Then, x = 4*rand(1,10)2; would do it for you.<br>
<br>
Best.

Thu, 18 Feb 2010 16:32:09 +0000
Re: picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718935
Wayne King
"Kenzo Mendoza" <kenzo_mendoza@knights.ucf.edu> wrote in message <hljnjv$7kr$1@fred.mathworks.com>...<br>
> Hi<br>
> I would like to initialize a vector with random numbers between 2 and 2<br>
> <br>
> would it be something like x=rand(1,10) *2?<br>
> <br>
> Any response will be greatly appreciated <br>
<br>
In addition to the help other posters have given you, if you have the Statistics Toolbox, you can use unifrnd()<br>
<br>
R = unifrnd(2,2,100,1);<br>
hist(R)<br>
<br>
Wayne

Thu, 18 Feb 2010 16:38:05 +0000
Re: picking random numbers between a certain range
http://www.mathworks.com/matlabcentral/newsreader/view_thread/274125#718940
Oleg Komarov
> Maybe it is more of a statistics question.<br>
> <br>
> If U is uniformly distributed over [0,1), then 4*U2 will be uniformly distributed over [2,2).<br>
> <br>
> Then, x = 4*rand(1,10)2; would do it for you.<br>
> <br>
> Best.<br>
<br>
Statistic or not, the example in the help is clear (and people should learn to read the help of a fcn before asking):<br>
<br>
Examples:<br>
Generate values from the uniform distribution on the interval [a, b].<br>
r = a + (ba).*rand(100,1);<br>
<br>
Oleg