% 标准调幅AM调制
a0=2;f0=10;fc=50;snr=3; fs=1000; % 变量定义
t=[-50:0.001:50];
am1=cos(2*pi*f0*t); % 产生信号频率为f0的基带信号
am=a0+am1; % 产生AM信号
c_am=cos(2*pi*fc*t); % 产生频率为fc的载波
AM_mod=am.*c_am; % 产生调制信号
am_f=fft(am); % AM频域
AM_modf=fft(AM_mod);
y=awgn(AM_mod,snr); % 叠加噪声
figure(1); hold on;
subplot(2,2,1); plot(t,am1); axis([0 0.4 -2 2]); title('基带信号波形'); % 绘图subplot(2,2,2); plot(t,am); axis([0 0.4 -2 6]); title('AM信号波形');
subplot(2,2,3); plot(t,c_am); axis([0 0.4 -2 2]); title('载波信号波形'); subplot(2,2,4); plot(t,AM_mod); axis([0 0.4 -8 8]); title('已调信号波形'); hold off;
figure(2); hold on;
subplot(2,2,1); plot(t,AM_mod); axis([0 0.4 -8 8]); title('已调信号波形'); subplot(2,2,2); plot(t,y); axis([0 0.4 -8 8]); title('叠加噪声后的信号波形');; a=[35,65];b=[30,70];
Wp=a/(fs/2);Ws=b/(fs/2);Rp=3; Rs=15;
[N,Wn]= Buttord(Wp,Ws,Rp,Rs) ; % 计算巴特沃斯数字滤波器的阶数和
3db截止频率
[B,A]=Butter(N,Wn,'bandpass'); % 计算巴特沃斯模拟滤波器系统函数的分子、分母多项式系数向量
sig_bandpass=filtfilt(B,A,y); % 带通滤波后信号
subplot(2,2,3); plot(t,sig_bandpass); axis([0 0.4 -8 8]); title('经带通滤波后信号波形');
hold off;
AM_dem=sig_bandpass.*c_am;
Wp=15/(fs/2);Ws=40/(fs/2);Rp=3; Rs=20;
[N,Wn]= Buttord(Wp,Ws,Rp,Rs) ; % 同上
[B,A]=Butter(N,Wn,'low');
AM_demod=filtfilt(B,A,AM_dem) % 低通滤波后信号
AM_demodf=fft(AM_demod);
subplot(2,2,4); plot(t,AM_demod); axis([0 0.4 0 2]); title('解调信号波形'); hold off;
f=(0:100000)*fs/100001-fs/2;
figure(3); hold on;