I have taken a clean speech signal and need to get an input SNR of 0dB, 5dB and 10dB by adding certain amount of white noise.
Can anyone explain what 0dB, 5dB... is? Is it the power of white noise in the command
noise=wgn(1,20115,0);
and if not, how do I achieve input SNR of 0dB, 5dB and 10dB?
The signal to noise ratio (SNR) is the signal power relative to the noise power. The easiest way to achieve a given SNR while adding White Gaussian Noise to a clean signal is with awgn:
input_snr_db = 5; % Choose input SNR in dB
noisy_signal = awgn(clean_signal, input_snr_db, 'measured');
This computes the required level of noise given a signal which may not have unitary power.
Related
If I wanted to get the SNR of a quantized audio signal, would I subtract the quantized signal from the original (which would give me the noise?) and then calculate the power of this noise and compare it to the power of the original signal?
Such as, SNR(dB)=10*log(original power/noise power)
Yes, that is the quantization noise. It is not just “noise” because the input has noise as well, and you don’t include that noise in your result.
I have a cosine signal and some interference consisting of a sine noise signal and a random noise signal. I am trying to add these noise signals to the cosine signal with an SNR of 2 dB. To achieve this I have done the following:
First, I have added the two noise signals to get a single noise signal;
then I have used Parseval's theorem to calculate the power of each signal, the cosine signal and the new resultant noise signal;
then I have edited the noise signal with the required power to achieve this SNR by normalizing it by the square root of its current power and multiplying it by the square root of the required power. The required power is derived from the formula of the SNR as :
Power of noise = power of the cosine signal / 10^SNR/10;
Finally, I have checked the new SNR and the result wasn't 2 dB.
Here is my code :
fs=250;
n=0:1/fs:4;
interference=sin(2*pi*(50)*n); % interference signal
random_noise=rand(size(n)); % random noise signal
noise_signal=interference+random_noise;% determinning the tottal noisy signal that will be added later
signal= cos(2*pi*(50)*n); % Definning signal of interest
signal_power=sum(abs(signal.^2)) ; %u sing parseval's theorem
current_noisy_signal_power=sum(abs(noise_signal.^2)); % using parseval's theorem
pn=signal_power/(10^(2/10)); % required SNR =2dB
new_noisy_signal=(noise_signal./sqrt(current_noisy_signal_power)).*sqrt(pn); % normalizing the noisy signal to get unity power then multiplying it by the new power to achieve the required SNR
new_noisy_signal_power=sum(abs(new_noisy_signal.^2));
SNR=10*log(signal_power/new_noisy_signal_power)
So what is wrong in my code? Why isn't the SNR 2 dB?
SNR is typically computed using the base-10 logarithm, which matches also with the way you computed 2dB: (10^(2/10)). So, use log10 instead of log when computing the SNR:
>> SNR = 10*log10(signal_power/new_noisy_signal_power)
SNR = 2.0000
Assuming I have two signals (raw data as excel file) measured from two different power supplies, I want to compare the noise-levels of these signals to find out which one of them the noisier one. Both power supplies produce signals with the same frequency but the amount of data points are different. Is there a way to do this in MATLAB?
You could calculate the signal-to-noise ratio for each signal. This is just a ratio of the average signal power and average noise power, usually measured in decibels. An ideal noiseless signal would have SNR = infinity.
Recall that signal power is just the square of the signal amplitude, and to get the value x in decibels, we just take 10*log10(x).
SNR = 10*log10( mean(signal.^2)/mean(noise.^2) );
To separate the signal from the noise, you could run a low-pass filter over the noisy signal.
To get the noise you could just subtract the clean signal from the noisy signal.
noise = noisy_signal - signal;
For Blind Source Separation (Adapative Filtering , LMS Algorithm), i need two input. a)noisy signal, 2)noise signal. But How can i make the noise signal. If i can estimate the noise variance of noisy signal, then how can i make a noise signal from noise variance in matlab. I am new in signal processing.
try this (matlab):
noise = normrnd(mean ,sqrt(variance) ,rows ,columns);
it will generate random numbers from the normal distribution (mean,variance).
rows and columns will dictate the result matrix dimensions.
So I have the samples (hex values) of a sinus signal and I know the sampling frequency. Using this I can plot an fft or periodogram but then I would like to find out the SNR ratio. What would be the most accurate way to calculate the noise and signal power? I would prefer doing it in frequency domain. Is there a way to do this also in time domain?
Thanks a lot in advance!!!
So if there is noise on your signal and you know that your underlying signal is a sine wave, you can easily get your signal parameters i.e. amplitude,frequency and phase by least squares. If y(t) is your signal just minimize the L2 norm of (y(t)-A.sin(wt+b)) over A,w and b. Then you can easily get signal power from the underlying signal and the noise power from the error signal (y(t)-A.sin(wt+b)).