Effacer les filtres
Effacer les filtres

Complex random variable with unity amplitude and uniform phase distribution?

6 vues (au cours des 30 derniers jours)
Hi,
I need to add a random phase shift to a vector. What can I use to create a complex random variable with unity amplitude and a uniform phase distribution over [0,2pi)?
Thank you!

Réponse acceptée

Ameer Hamza
Ameer Hamza le 29 Sep 2020
n = 1000; % generate n complex numbers
mag = 1; % magnitude of complex numbers
phases = rand(1, n)*2*pi; % phases of complex numbers from 0 to 2*pi
[re, im] = pol2cart(phases, mag);
rand_complex = re + im*1i;
  2 commentaires
Davide Mori
Davide Mori le 29 Sep 2020
Thank you for the quick answer!
Ameer Hamza
Ameer Hamza le 29 Sep 2020
I am glad to be of help! :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by