I am a little unsure about the generation of a additive white Gaussian noise, so I would appreciate to hear from you if I`m doing it correctly.
My goal is to generate the time-domain noise correspondent to a noise floor of -135 dbm/Hz
The procedure I`m adopting is the following:
1 - Convert the noise floor in dbm/Hz to Watts/Hz
2 - Get the average total power from the PSD.
3 - Generate the Gaussian noise with this average total power
4 - Take the FFT of the Gaussian noise and estimate the periodogram to verify whether it is indeed generating the noise with the correct PSD
Here is how I do the 4 steps above:
1 - \begin{align} S_\text{watts} = \left(10^{\frac{S_\text{dBm}}{10}}\right)10^{-3} \end{align} where $S_\text{watts}$ is the PSD in Watts/Hz and $S_\text{dBm}$ is the PSD in dBm/Hz.
2 - Average total power is given by $$ P_n = S_\text{watts} B ,$$ where $B$ is the Bandwidth
3 - Generate the randn MATLAB function multiplied by $\sqrt{P_n}$.
4 -
4.1 Take the FFT of the signal, let`s say, $X(k)$.
4.2 Get the Energy Spectral Density (ESD) as $\frac{\left| X(k) \right|^2}{N}$
4.3 Get the PSD by simply dividing the ESD by $N$ (the FFT length)
4.4 I do not simply plot the $10 \log_{10}\left(\text{PSD} 10^3\right)$, since I believe this would plot the PSD in dBm/subcarrier. Instead of this, I plot $10 \log_{10}\left(\frac{\text{PSD}}{\text{tone spacing}} 10^3\right)$, in attempt to get the plot as dBm/Hz.
The code below is what I am using. Please, indicate if I`m doing any mistake.
clear all
clc
bandwidth = 106e6; % in Hz
sampleFrequency = 2*bandwidth; % in Hz
noiseFloor = -135; % in dBm/Hz
awgnPsd = (10.^(noiseFloor/10))*1e-3; % in Watts/Hz
noisePower = awgnPsd*2*bandwidth; % in Watts
% Generate noise signal:
N = 4096; % signal length
nSymbols = 1000; % number of symbols with length N to be generated
noise = randn(N,nSymbols)*sqrt(noisePower);
% Verify PSD
toneSpacing = sampleFrequency/N; % DFT tone spacing
ESD = mean(abs(fft(noise,N)).^2)/N; % Energy spectral density
PSD = ESD/N;
% plot PSD
figure
plot(10*log10((PSD/toneSpacing)*1e3))