snrmse.m

来自「经典书籍《通信系统仿真原理与无线应用》chap8部分课后题仿真源代码」· M 代码 · 共 19 行

M
19
字号
function [gain,delay,px,py,rxy,rho,snrdb] = snrmse(x,y)
ln = length(x);               % length of the reference (x) vector
fx = fft(x,ln);                 % FFT the reference (x) vector
fy = fft(y,ln);                 % FFT the measurement (y) vector
fxconj = conj(fx);             % conjugate the FFT of the reference vector
sxy = fy .* fxconj;             % determine the cross PSD
rxy = ifft(sxy,ln);              % determine the cross correlation function
rxy = real(rxy)/ln;             % take the real part and scale
px = x*x'/ln;                  % determine power in reference vector
py = y*y'/ln;                  % determine power in measurement vector
[rxymax,j] = max(rxy);         % find the max of the cross correlation
gain = rxymax/px;            % system gain
delay = j-1;                  % system delay
rxy2 = rxymax*rxymax;        % square rxymax for later use
rho = rxymax/sqrt(px*py);      % correlation coefficient
snr = rxy2/(px*py-rxy2);        % snr
snrdb = 10*log10(snr);         % snr in db
% End of function file.

⌨️ 快捷键说明

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