📄 sig_noi.m
字号:
% ----------------------------------------
% +++++ Simulation of Noisy received Signal +++++++
% (Note: This is a digital simulation of the analog receiver)
% ----------------------------------------
clear all ; close all;
s0 = 3*ones(1,100) ; % Transmitted signal s0
s1 = 3*[ones(1, 50) -ones(1,50)] ; % Transmitted signal s1
h0 = 3*ones(1,100) ; % impulse response for s0
h1 = 3*[-ones(1, 50) ones(1,50)] ; % impulse response for s1
%
%%% Transmitting a sequence of bits .......
%
ss = [s0 s1 s1 s0] ; % Transmitted signal ----> 0110
rr0 = conv(ss, h0);
rr1 = conv(ss, h1);
xx3 = [0:498];
figure(1);
subplot(3,1,1); plot(1:400,ss) ; axis([-50 550 -4 4]); grid;
title('Transmitted signal for 0110');
subplot(3,1,2); plot(xx3,rr0) ; axis([-50 550 -1000 1000]); grid;
title('r0 output for 0110');
subplot(3,1,3); plot(xx3,rr1) ; axis([-50 550 -1000 1000]); grid;
title('r1 output for 0110');
xlabel('Time (Tb=100)');
%
% Simulation of white Gaussian noise - WGN
%
E = 3*3*100;
snr_db = 20 ;
snr = exp(snr_db*log(10)/10) ;
sig = sqrt(E/(2*snr)) ; % this is the noise (input) std deviation
n0 = sig*randn(1,4*100);
n1 = sig*randn(1,4*100);
% now AWGN ....
rr0 = conv(ss+n0, h0);
rr1 = conv(ss+n1, h1);
figure(2);
subplot(3,1,1); plot(1:400,n0,1:400,n1) ; axis([-50 550 -4 4]); grid;
title('Two Noise signals');
subplot(3,1,2); plot(xx3,rr0) ; axis([-50 550 -1000 1000]); grid;
title('r0 output for 0110');
subplot(3,1,3); plot(xx3,rr1) ; axis([-50 550 -1000 1000]); grid;
title('r1 output for 0110');
xlabel('Time (Tb=100)');
%
% Following shows some properties of noise signals .....
%
LL = 8192 ; % length of noise sequence
nn = randn(1,LL) ;
% do the autocorrelation via efficient FFT processing
ff = fft(nn) ; % FFT of noise
ac = ifft(abs(ff).^2)/LL ;
% pick only PP autocorrelation lags for plotting...
PP = 64 ;
acn = [ac(LL:-1:LL-PP+1), ac(1:PP)] ;
figure(3) ;
subplot(2,1,1); plot(-PP:-1+PP, real(acn)) ; grid ;
xlabel('Lag (in samples)');
title('WGN - Autocorrelation and Power Spectrum');
% plot noise spectrum using FFT of of acn ...
subplot(2,1,2); plot(0.5*(-PP:-1+PP)/PP, abs(fft(real(acn))).^2) ;
axis([-0.5 0.5 0 1.5]); grid ;
xlabel('Normalized Frequency');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -