Effacer les filtres
Effacer les filtres

Create spatially colored noise given the noise covariance matrix.

16 vues (au cours des 30 derniers jours)
Yara
Yara le 4 Jan 2024
Commenté : Jaynik le 12 Jan 2024
I want to generate colored noise samples given the noise covariance matrix and the SNR. I assumed that the source signal power is Ps = 1 W and hence find the noise power Pn. The noise covariance matrix is:
Qm,l = σn^2 * exp{−0.5(m − l)^2}
where m and l are indices of the covariance matrix Q (9 x 9) and σn is the noise variance (hence σn = Pn).
How can I generate noise samples from this given data?

Réponse acceptée

Jaynik
Jaynik le 9 Jan 2024
Hi Yara,
I understand that you want to generate colored noise samples from the noise covariance matrix and the SNR (Signal-to-noise ratio).
You can follow these steps in MATLAB:
  1. Calculate the noise power "Pn" based on the SNR and the source signal power "Ps".
  2. Define the noise covariance matrix "Q" using the given formula for Qm,l.
  3. Generate samples from a multivariate normal distribution using the defined matrix "Q".
Here is a sample code to generate the noise sample:
N = 9;
Pn = Ps / SNR;
Q = zeros(N, N);
for m = 1:N
for l = 1:N
Q(m, l) = Pn * exp(-0.5 * (m - l)^2);
end
end
% Assuming that you want to generate a single sample vector
noiseSample = mvnrnd(zeros(1, N), Q);
% If you want to generate multiple samples, say 1000 samples, you can use:
% noiseSamples = mvnrnd(zeros(1, N), Q, 1000);
disp(noiseSample);
When you generate a sample from a multivariate normal distribution with this covariance matrix using the "mvnrnd" function, you get a vector of noise samples that are correlated according to the structure defined by "Q". This is what makes the noise "colored" because the values are not independent.
Note that if the "SNR" is given in decibels (dB), you will need to convert it to linear scale using SNR_linear = 10^(SNR_db/10) before using it in the calculation of "Pn".
You can refer the following documentation to read more about "mvnrnd":
Hope this helps!
  2 commentaires
Yara
Yara le 11 Jan 2024
thank you for your reply. If I have 2 sources where each one has a power, should I add both powers to get Ps and then find Pn?
Also, the noise is complex, so does this line become the following?
% Assuming that you want to generate a single sample vector
noiseSample = mvnrnd(zeros(1, N), Q) + 1j* mvnrnd(zeros(1, N), Q)
or should I multiply by the normalized power?
% Assuming that you want to generate a single sample vector
noiseSample = np.sqrt(Pn/(2*Pn)) * ( mvnrnd(zeros(1, N), Q) + 1j* mvnrnd(zeros(1, N), Q) )
Jaynik
Jaynik le 12 Jan 2024
Hey @Yara,
You are correct that when you have two sources, the total signal power "Ps" is the sum of the individual powers of each source as the overall energy detected by a receiver is the cumulative energy from all sources.
Regarding the complex noise generation, you should multiply by the normalized power but there won't be a "Pn" in the denominator as it would incorrectly normalize the noise power to a constant value, independent of "Pn".
According to me the code should look like this:
noiseSample = sqrt(Pn/2) * (mvnrnd(zeros(1, N), Q) + 1j * mvnrnd(zeros(1, N), Q));

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by