From: Jouko on
I've been working with a signal analysis task, which should
include actual and correct amplitudes. My problem is when
converting signal+noise to frequency domain, noise level is
too low.

For example noise floor simulation:
-----------------

% Generate signal
Fs = 10000; % Sampling frequency
dt = 1/Fs; % Frequency resolution
N = 2^16; % Sampled points
T = N*dt; % Sampling period
df = 1/T; % Fundamental frequency
Nf = N/2 + 1; % Nyquist frequency

f = 1526; % Nice frequency with little scalloping loss..
A = 1; % Signal amplitude in volts
t = dt:dt:T; % Time vector

% Generate noise
kf = 1.38065E-23; % Boltzmann constant J/K
T_abs = 25 + 273.15; % Absolute temperature in K
Res = 50; % Ohms
BW = 5000;

thermal_noise_floor = sqrt(4*kf*T_abs*BW*Res); % RMS noise
floor in volts
noise_vector = thermal_noise_floor * randn(size(t)); % In
volts

% Combine signal + noise
y1 = A*sin(2*pi*f*t);
ydata = y1 + noise_vector;

% Frequency analysis + plot
ydata = ydata.*(hann(N)'*2); % Compensate Hanning window's
coherent gain
f = Fs/2*linspace(0,1,N/2); % Frequency vector up to Fn

X = fft(ydata)/N;
X = X(1:Nf); % Cut spectrum to Fn
Ax = 20*Log10(2*abs(X(2:Nf))); % Calculate magnitude spectrum
figure, plot(f,Ax)
title('Frequency domain of simulated signal')
ylabel('Magnitude [dBV]')
xlabel('Frequency')

---------------

This simulation results in RMS noise floor level of 0.064
microvolts, which equals about -144 dBV. But when
calculating the FFT + magnitude spectrum, one can see from
the spectrum that noise floor is at about -174 dBV!

Where is it going wrong?