clear
clc
Fs=10000; %采样频率
Fc=1000; %载波频率
T=0.1; %观察区间
Ns=Fs*T; %信号观察总长度
t=0:1/Fs:(Ns-1)/Fs;
A0=6;  %调制偏移电平
x=2*cos(2*pi*50*t)+cos(2*pi*20*t);%原始调制信号
psdx=pwelch(x,[],[],1000,Fs);
u1=ammod(x,Fc,Fs,0,A0);%已调AM信号
psdu1=pwelch(u1,[],[],1000,Fs);
snr=-5;
u1z=awgn(u1,snr);
psdu1z=pwelch(u1z,[],[],1000,Fs);
w1=(Fc-50)*2/Fs;
w2=(Fc+50)*2/Fs;
[b,a]=butter(5,[w1,w2]);
u1zd=filter(b,a,u1z);
psdu1zd=pwelch(u1zd,[],[],1000,Fs);
z = amdemod(u1zd,Fc,Fs,0,A0);
psdz=pwelch(z,[],[],1000,Fs);
subplot(5,1,1);plot(psdx);
title('原始调制波形');xlim([0,200])
subplot(5,1,2);plot(psdu1)
title('AM已调波形');xlim([0,200])
subplot(5,1,3);plot(psdu1z)
title('叠加噪声波形');xlim([0,200])
subplot(5,1,4);plot(psdu1zd)
title('带通滤波后波形');xlim([0,200])
subplot(5,1,5);plot(psdz)
title('解调后波形');xlim([0,200])