Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

vickyuet

Member level 2
Joined
Oct 3, 2006
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
pakistan
Activity points
1,691
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
Joined
Jul 22, 2009
Messages
317
Helped
61
Reputation
136
Reaction score
44
Trophy points
1,318
Location
Egypt
Activity points
2,963
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
Joined
Mar 13, 2009
Messages
170
Helped
51
Reputation
102
Reaction score
49
Trophy points
1,308
Activity points
2,238
That's the way to do it. What's wrong?
 

vickyuet

Member level 2
Joined
Oct 3, 2006
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
pakistan
Activity points
1,691
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top