描述:对ADC的数据FFT变换后,进行SNR,SINAD,ENOB,THD计算编程;
问题:在计算SNR时,对span这个计算的方式不明白(如下公式),存在如下问题;
span=max(round(N/200),5);N为数组长度
1、N/200表示什么意思;
2、span代表带宽,在round函数之后,为什么与5对比,取出来的span这个值是什么意思?
具体代码如下,谢谢!
%%%%%%%%%前面的代码已省略,是对输入数据的设置,比如len/fs等%%%%%%
x=hann(N);
for i=1:N;
data_win(i)=x(i)*DOUT_sum_uni(i);
end
x1=norm(x,1); %?????ó??
Dout_spect=fft(data_win,N)/(x1);
%recalculate to dB
Dout_dB=20*log10(abs(Dout_spect));
%display the results in the frequency domain with FFT plot
figure;
maxdB=max(Dout_dB(2:N/2));
%%for TTIMD,use the following short routine,normalized to -6.5dB
%full scale.
plot([0:N/2-1].*(fs/N),Dout_dB(1:N/2)-maxdB);
grid on;
title('FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY(KHz)');
ylabel('AMPLITUDE(dB)');
%-----------------------------------------------%
%calculate SNR,SINAD,ENOB,THD and SFDR values
%-----------------------------------------------%
%find the signal bin number, DC=bin 1
fin=find(Dout_dB(1:N/2)==maxdB);
%double to int
%Span of the input freq on each side
span=max(round(N/200),5);
%approximate search span for harmonics on each side
spanh=2;
%determine power spectrum
spectP=(abs(Dout_spect)).*(abs(Dout_spect));
%find DC offset power
Pdc=sum(spectP(1:span));