- Calculate the noise power "Pn" based on the SNR and the source signal power "Ps".
- Define the noise covariance matrix "Q" using the given formula for Qm,l.
- Generate samples from a multivariate normal distribution using the defined matrix "Q".
Create spatially colored noise given the noise covariance matrix.
18 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Jaynik
on 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:
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 Comments
Jaynik
on 12 Jan 2024
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));
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!