Bill
Posts:
24
Registered:
12/7/04


How to generate ONE random number between TWO intervals??
Posted:
Sep 30, 2008 10:19 AM


Hi all,
I need to generate a single random number between two intervals. For example, how would I use the "rand()" function to generate a random number between the intervals of: [2, 1] AND [1,2]. If I needed a random number between [1,2], I know I can just simply use:
r = a + (ba).*rand(100,1);
where a=1 and b=2. Any ideas on how to apply this equation to get a random number between the 2 intervals listed above?
Thanks in advance, weg22

