通信原理实验报告三
实验内容:
用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');