saket wrote on Jun 17th, 2009, 5:07am:The input signal in the Hanning window is spread over 3 bins.
I'm assuming that in order to calculate the SNR, the signal power in all the 3 bins has to be added up.
Is this a correct assumption?
Again see M-File of
http://www.designers-guide.org/Forum/YaBB.pl?num=1213204643/8#8The followings are extractions from them.
Quote:%Parameters
order = 2;
nLev = 2;
opt = 2;
H_inf = 1.6;
fs = 1e6;
%f0 = 1/4;
f0 = 20e3/fs; % Normalized by fs
%OSR = 128;
BW = 4e3;
OSR = fs/(2*BW);
fprintf(stdout, 'OSR=%d\n', OSR);
Nfft = 2^13;
Tstep = 1; % Normalized by (1/fs)
Textra = 100*Tstep;
Tstop = Nfft*Tstep + Textra;
delta_f = 1/(Tstop-Textra);
%tone_bin=57;
tone_bin = fix(f0/delta_f + 0.5);
if mod(tone_bin, 2) == 0
tone_bin = tone_bin + 1;
end
fprintf(stdout, 'tone_bin=%d\n', tone_bin);
t1 = fix(Textra/Tstep);
t2 = t1 + Nfft-1;
t = 0:t2;
u = 0.5*(nLev-1)*sin(2*pi*(tone_bin)/Nfft*t);
n = 1:150;
n = n + t1;
%Calculating the Spectral Contents of the modulator
%Determining the SNR
figure(4), hold on
spec = fft( v(t1:t2) .* hann(Nfft) ) / (Nfft*(nLev-1)/4);
snr = calculateSNR(spec(1:ceil(Nfft/(2*OSR))+1), tone_bin);
NBW = 1.5/Nfft;
f = linspace(0, 0.5, Nfft/2+1);
plot(f, dbv(spec(1:Nfft/2+1)), 'b')
%z = exp(2i*pi*f); Sqq = 4*( evalTF(H, z) / (nLev-1) ) .^ 2/3;
Sqq = 4*( freqresp(H, 2*pi*f) / (nLev-1) ) .^ 2/3;
plot(f, dbp(squeeze(Sqq)*NBW), 'm', 'Linewidth', 1);
grid on
If you see
"delsig/calculateSNR.m" and
"delsig/hann.m" of
http://www.mathworks.com/matlabcentral/fileexchange/19,
you will be able to find out answer to your questions.
The followings are extractions from "delsig/DSToolbox.pdf".
Quote:Delta-Sigma Utility
snr = calculateSNR(hwfft, f)
Estimate the SNR given the in-band bins of a Hann-windowed FFT and the location of the input signal.
window = hann(N)
A Hann window of length N. Unlike MATLAB’s original hanning function,
hann does not smear tones which are located exactly in an FFT bin (i.e. tones having an integral number of cycles in the given block of data).
MATLAB 6’s hanning(N, ’periodic’) function is the same as hann(N).