www.gusucode.com > 设计并仿真以下无线系统matlab源码程序 > ask.m
clear all; fm=10000; %载波信号频率1MHZ fc=1000000;%调制信号频率10KHZ dt=0.0000001; %采样间隔<1/(2fc) t=[0:dt:0.001];%时间长度为调制信号整数个周期 ct=cos(2*pi*fc*t);%载波信号 mt0=cos(2*pi*fm*t);%调制信号 mt=mt0+2; dsb=mt.*ct;%DSB已调信号 N=1000; f=(-N/2:N/2-1)/N*(1/dt); X1=fftshift(fft(mt,N));% 调制信号傅里叶变换求频谱 X2=fftshift(fft(ct,N)); % 载波信号傅里叶变换求频谱 X3=fftshift(fft(dsb,N)); % DSB已调信号傅里叶变换求频谱 figure(1) subplot(3,1,1),plot(t,mt),title('调制信号'),axis([0,0.0001,-1,1]);%坐标轴范围 subplot(3,1,2),plot(t,ct),title('载波信号'),axis([0,0.0001,-1,1]) subplot(3,1,3),plot(t,dsb),title('已调信号'),axis([0,0.0001,-1,1]) figure(2); subplot(3,1,1),plot(f,X1);title('调制信号频谱');axis([-2000000,2000000,-2,600]); subplot(3,1,2),plot(f,X2);title('载波信号频谱');axis([-2000000,2000000,-2,600]); subplot(3,1,3),plot(f,X3);title('已调信号频谱');axis([-2000000,2000000,-2,600]); r_dsb=awgn(dsb,10);% +高斯白噪声,(接收信号) figure(3) subplot(2,1,1),plot(t,r_dsb),title(' +高斯白噪声'),axis([0,0.0002,-2,2]) w1=2*dt*990000;%带通滤波器低频率fc-fm w2=2*dt*1010000;% 带通滤波器高频率fc+fm [b,a]=butter(4,[w1,w2],'bandpass'); %巴特沃斯带通滤波器 r_dsb1=filter(b,a,r_dsb); %接收信号经过带通滤波器滤波 subplot(2,1,2),plot(t,r_dsb1),title('信号进入带通滤波器'),axis([0,0.0002,-2,2]) r_dsb2=r_dsb1.*ct; %与相干载波相乘 w3=2*dt*10000; %低通滤波器频率 [b,a]=butter(6,w3,'low'); %低通滤波器 r_dsb3=filter(b,a,r_dsb2); %经过低通滤波器滤波 figure(4) subplot(2,1,1),plot(t,r_dsb2);title('与相干载波相乘输出'),axis([0,0.0005,-1.5,1.5]) subplot(2,1,2),plot(t,r_dsb3);title('解调输出'),axis([0,0.0005,-0.5,0.5])