c8_snrexample.m

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

M
32
字号
% File: c8 snrexample.m
kpts = 1024;                         % FFT Block size
k = 1:kpts;                           % sample index vector
fd = 2;                              % desired signal frequency
fi = 8;                               % interference frequency
Ax = 80; Ayd = 20; Ayi =4;             % amplitudes
phase = pi/4;                        % phase shift
nstd = 0.8;                          % noise standard deviation
%
theta = 2*pi*k/kpts;                   % phase vector
x = Ax*sin(fd*theta);                  % desired signal
yd = Ayd*sin(fd*theta+pi/4);           % desired signal at receiver input
yi = Ayi*sin(fi*theta);                  % interference
noise = nstd*randn(1,kpts);            % noise at receiver input
yy = yd+yi+noise;                    % receiver input
[gain,delay,px,py,rxy,rho,snrdb] = snrmse(x,yy);
%
% display results
%
cpx = ['The value of Px is ',num2str(px),'.'];
cpy = ['The value of Py is ',num2str(py),'.'];
cgain = ['The value gain is ',num2str(gain),'.'];
cdel = ['The value of delay is ',num2str(delay),'.'];
csnrdb = ['The value of SNR is ',num2str(snrdb),'dB.'];
disp(' ') % insert blank line
disp(cpx)
disp(cpy)
disp(cgain)
disp(cdel)
disp(csnrdb)
% End of script file.

⌨️ 快捷键说明

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