📄 lab3_1(a).m
字号:
% c=20;
% seq=[-5,5,-5,-5,5,-5,5,-5,5,-5,5,5];
% for j=1:10;
% L=seq(j);
% for i=1:c
% x((j-1)*20+i)=L
% end;
% end;
% subplot(211);
%
% %subplot(2,1,1);
%
% %noise generation
% n=randn(c*10,1);
% plot(n);
% for i=1:c*10;
% y(i)=x(i)+n(i);
% end;
% subplot(222);
% plot(y);
%
% %matched filter
% for i=1:20
% n(i)=pulse(c-i+1)
% end;
% %output of matched filter
% t=conv(y,h)*1/20
% subplot
% plot(t);
%
% n1=randn(c*10,1)*200
% n2=randn(c*10,1)*0.3
%SIMULATION OF AWGN CHANNEL
%generating a rect. amplitude +/-5 pulse sequence
clear;
clf;
e=20; %sample time
seq=[-5 5 -5 -5 5 -5 5 -5 5 5]; %pulse sequence
for j=1:10,
L=seq(j);
for i=1:e,
x((j-1)*20+i)=L; %generating the pulse train
end
end
%subplot(211);
%plot(seq);
subplot(411);
plot(x);
grid on;
ylim([-10 10]);
title('Original Signal');
%to generate unit variance gaussian noise
%sequence of the same length
%n=randn(e*10,1);
%n=randn(e*10,1)*200;
n=randn(e*10,1)*0.3%n=randn(e*10,1)*200;;
subplot(412);
plot(n);
grid on;
title('Additive White Gaussian Noise with unit variance');
%signal corrupted with white noise
for i=1:e*10,
y(i)=x(i)+n(i);
end
subplot(413);
plot(y);
grid on;
title('Corrupted signal');
%SIMULATION OF MATCHED FILTER
for i=1:20,
h(i)=pulse(e-i+1);
end
%output of matched filter t
t=conv(y,h)*1/20;
subplot(414);
plot(t);
grid on;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -