⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calcsnr.m

📁 toolbox of sdt implementation
💻 M
字号:
function [snrdB,ptotdB,psigdB,pnoisedB] = calcSNR(vout,f,fBL,fBH,w,N)
% SNR calculation in the time domain (P. Malcovati, S. Brigati)
%
% [snrdB,ptotdB] = calcSNR(vout,f,fBL,fBH,w,N)
% [snrdB,ptotdB,psigdB] = calcSNR(vout,f,fBL,fBH,w,N)
% [snrdB,ptotdB,psigdB,pnoisedB] = calcSNR(vout,f,fBL,fBH,w,N)
%
% vout:     	Sigma-Delta bitstream taken at the modulator output
% f:    		Normalized signal frequency (fs = 1)
% fBL:			Base-band lower limit frequency bins
% fBH:			Base-band upper limit frequency bins
% w:			Windowing vector
% N:			Number of samples
%
% snrdB: 	 	SNR in dB
% ptotdB:  		Sigma-Delta modulator output power spectral density (vector) in dB
% psigdB:	 	Extracted signal power spectral density (vector) in dB
% pnoisedB:		Noise power spectral density (vector) in dB

fBL=ceil(fBL);
fBH=ceil(fBH);
signal=(N/sum(w))*sinusx(vout(1:N).*w,f,N);	% Extracts sinusoidal signal
noise=vout(1:N)-signal;			            % Extracts noise components
stot=((abs(fft((vout(1:N).*w)'))).^2);		% Bitstream PSD
ssignal=(abs(fft((signal(1:N).*w)'))).^2;	% Signal PSD
snoise=(abs(fft((noise(1:N).*w)'))).^2;		% Noise PSD

pwsignal=sum(ssignal(fBL:fBH));	            % Signal power
pwnoise=sum(snoise(fBL:fBH));		        % Noise power

snr=pwsignal/pwnoise;
snrdB=dbp(snr);
norm=sum(stot(1:N/2))/sum(vout(1:N).^2)*N;	% PSD normalization
if nargout > 1
	ptot=stot/norm; 
	ptotdB=dbp(ptot);
end

if nargout > 2
	psig=ssignal/norm;
	psigdB=dbp(psig);
end

if nargout > 3
	pnoise=snoise/norm;
	pnoisedB=dbp(pnoise);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -