Thread Subject: Unique Random Numbers

Subject: Unique Random Numbers

From: Jarrod

Date: 12 Nov, 2008 00:25:03

Message: 1 of 3

I'm creating a random complex signal that consists of a real and imaginary part. The coefficient of each part comes from a predetermined alphabet. Providing the code below:

N=10;
alpha = [-sqrt(3)/2 -1/2 sqrt(3)/2 1/2];
tx = randsrc(1,N,alpha)+j*randsrc(1,N,alpha);

The only problem with this is that I need the real and imaginary parts to always be different. If you examine my alpha closely, it's points on the unit circle; however the points are only accurate if real does not equal imaginary. Any suggestions on how to use the same fix this? Thanks.

Subject: Unique Random Numbers

From: Trevis Crane

Date: 12 Nov, 2008 04:26:03

Message: 2 of 3

A very unelegant way would be to generate your real and imag parts separately

rl = randsrc(1,N,alpha);
im = randsrc(1,N,alpha);

and remove the pairs that are identical

rl(rl == im) = [];
im(rl == im) = [];

You can repeat this iteratively until you have a total number of N pairsthat you need and then create your tx:

tx = rl + j*im;

just a first idea...

"Jarrod " <jrmfzf@gmail.com> wrote in message <gfd7ov$46p$1@fred.mathworks.com>...
> I'm creating a random complex signal that consists of a real and imaginary part. The coefficient of each part comes from a predetermined alphabet. Providing the code below:
>
> N=10;
> alpha = [-sqrt(3)/2 -1/2 sqrt(3)/2 1/2];
> tx = randsrc(1,N,alpha)+j*randsrc(1,N,alpha);
>
> The only problem with this is that I need the real and imaginary parts to always be different. If you examine my alpha closely, it's points on the unit circle; however the points are only accurate if real does not equal imaginary. Any suggestions on how to use the same fix this? Thanks.

Subject: Unique Random Numbers

From: Roger Stafford

Date: 12 Nov, 2008 06:31:02

Message: 3 of 3

"Jarrod " <jrmfzf@gmail.com> wrote in message <gfd7ov$46p$1@fred.mathworks.com>...
> I'm creating a random complex signal that consists of a real and imaginary part. The coefficient of each part comes from a predetermined alphabet. Providing the code below:
>
> N=10;
> alpha = [-sqrt(3)/2 -1/2 sqrt(3)/2 1/2];
> tx = randsrc(1,N,alpha)+j*randsrc(1,N,alpha);
>
> The only problem with this is that I need the real and imaginary parts to always be different. If you examine my alpha closely, it's points on the unit circle; however the points are only accurate if real does not equal imaginary. Any suggestions on how to use the same fix this? Thanks.
---------
  If you want your complex values to lie on some curve in the complex plane such as the unit circle, you should be generating your random values as a single random parameter from which the real and imaginary parts are derived, not from two independent random sources.

  In the example you give, you should have:

 alpha = pi/6*[1,2,4,5,7,8,10,11];
 tx = exp(randsrc(1,N,alpha)*j); % <-- Where j is sqrt(-1)

Roger Stafford

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
random Jarrod 11 Nov, 2008 19:30:20
unique Jarrod 11 Nov, 2008 19:30:20
complex Jarrod 11 Nov, 2008 19:30:20
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com