1
$\begingroup$

I want to add complex wgn to a signal for a specified SNR. I have been using the following lines:

SNR = -10:5:50;
for l = 1:length(SNR)
   SignalN = awgn(Signal, SNR(l),'measured','dB');
end

where $Signal$ is the actual complex damped signal and the $SNR$ is in dB. I want to replace the above line with $randn$ function in MATLAB that considers the definition of WGN and SNR in dB. can someone help me with this?

$\endgroup$
5
  • $\begingroup$ just type edit awgn.m and you access to the source code of the awgn() function. $\endgroup$
    – AlexTP
    Jun 14 '21 at 10:50
  • $\begingroup$ Do you want to noise to be complex as well ? $\endgroup$
    – Hilmar
    Jun 14 '21 at 11:09
  • $\begingroup$ Thank you AlexTP. I do not want to continue using awgn, instead I want to use randn function that fulfils the same requirement as awgn. $\endgroup$
    – Neuling
    Jun 14 '21 at 11:10
  • $\begingroup$ Hi Hilmar. Yes I want it to be complex WGN, but without using the awgn or wgn functions from MATLAB. I want it to be with randn function in MATLAB $\endgroup$
    – Neuling
    Jun 14 '21 at 11:11
  • $\begingroup$ @Neuling well, if you ever look at the implementation of awgn(), it does use randn(). $\endgroup$
    – AlexTP
    Jun 14 '21 at 12:35
1
$\begingroup$
%  create complex white normal noise 
noise = randn(size(Signal)) + 1i*randn(size(Signal));
% calculate the gain for the noise
noiseGain = rms(Signal)./rms(noise)*exp(-SNR(i)*log(10)/20);
% add it
SignalN = Signal + noiseGain*noise;
$\endgroup$
2
  • $\begingroup$ Thank you Hilmar. I was not aware of the noise gain formula. Could you please correct the logarithmic function in the second line.. the brackets are missing. $\endgroup$
    – Neuling
    Jun 14 '21 at 11:39
  • $\begingroup$ Done. Should have been $log(10)$. It's just turning dB into a linear gain $\endgroup$
    – Hilmar
    Jun 15 '21 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.