# uniformly distributed random number from 0 to 2*pi in MATLAB

Status
Not open for further replies.

#### vickyuet

##### Member level 2
Rand generates uniformly distributed random values between [0 to 1], but I need values from [0 to 2*pi].Is there any method to explicitly force rand to generate values from above desired range instead of default [0 to 1]?.I had tried
Angle = (2*pi) * rand(1,10)
but not convinced.Any other approach or function to do this….

Last edited:

#### Ahmed Alaa

##### Full Member level 5
Re: uniformlydistributed random number from 0 to 2*pi in MATLAB

Angle = (2*pi) * rand(1,10) is correct why aren't you convinced ?

#### etmabreu

##### Full Member level 3
That's the way to do it. What's wrong?

#### vickyuet

##### Member level 2
I want a function that take an argument(as limits like 0 to 2pi) .....If there is any option to change rand to overwrite values from 0 t0 1 as 0 to 2pi.....some thing like

rand(1,10,0,2*pi) % to generate 1x10 row vector all values from 0 t0 2pi instead 0 t0 1....

- - - Updated - - -

I want a function that take an argument(as limits like 0 to 2pi) .....If there is any option to change rand to overwrite values from 0 t0 1 as 0 to 2pi.....some thing like

rand(1,10,0,2*pi) % to generate 1x10 row vector all values from 0 t0 2pi instead 0 t0 1....

Status
Not open for further replies.