Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us