通信原理实验报告三实验内容 :用 matlab 编写 2ASK ,2PSK 程序实验一: 2ASK 程序A=1; fc=2; N_sample=8; N=500; Ts=1; dt=Ts/fc/N_sample; t=0:dt:N.*Ts-dt; Lt=length(t); %产生二进制信源d=sign(randn(1,N)); dd=sigexpand((d+1)/2,fc.*N_sample); gt=ones(1,fc.*N_sample); %NRZ 波形figure(1); subplot(2,1,1); d_NRZ=conv(dd,gt); plot(t,d_NRZ(1:length(t))); axis([0 10 0 1.2]); ylabel(' 输入信号 ') %2ASK 信号ht=A.*cos(2.*pi.*fc.*t); s_ask=d_NRZ(1:Lt).*ht; subplot(2,1,2); %画图plot(t,s_ask); axis([0 10 -1.2 1.2]); ylabel('2ASK'); %常用到的子函数sigexpand.m function [out]=sigexpand(d,M); %将输入序列扩展成间隔为N-1 个 0 的序列N=length(d); out=zeros(M,N); out(1,:)=d; out=reshape(out,1,M.*N);实验二: 2PSK 程序A=1; fc=2; N_sample=8; N=500; Ts=1; dt=Ts/fc/N_sample; t=0:dt:N.*Ts-dt; Lt=length(t); %产生二进制信源d=sign(randn(1,N)); dd=sigexpand((d+1)/2,fc.*N_sample); gt=ones(1,fc.*N_sample); %NRZ 波形figure(1); subplot(2,1,1); d_NRZ=conv(dd,gt); dd_NRZ=2*d_NRZ-1; plot(t,d_NRZ(1:Lt)*2-1); axis([0 10 0 1.2]); ylabel(' 输入信号 ') %2PSK 信号ht=A.*sin(2.*pi.*fc.*t); s_psk=dd_NRZ(1:Lt).*ht; subplot(2,1,2); %画图plot(t,s_psk); axis([0 10 -1.2 1.2]); ylabel('2PSK');