2ASK、2FSK、2PSK数字调制系统的Matlab实现及性能分析与比较引言:数字带通传输系统为了进行长距离传输,克服传输失真,传输损耗,同时保证带内特性。必须对数字信号进行载波调制,将信号频谱搬移到高频段才能在信道中传输,因而现代通信系统采取数字调制技术。通过数字基带信号对载波某些参量进行控制,使之随机带信号的变化而变化。根据控制载波参量大的不同,数字调制有调幅(ASK),调频(FSK),调相(PSK)三种基本形式。Matlab用于仿真,分析和修改,还可以应用图形界面功能GUI能为仿真系统生成一个人机交互界面,便于仿真系统的操作,因此采用matlab对数字系统进行仿真。通过对系统的仿真,我们可以更加直观的了解数字调制系统的性能()及影响性能的因素,从而便于改进系统,获得更佳的传输性能。关键词:数字.系统.性能.ASK.FSK.PSK.Matlab.仿真.一.数字调制与解调原理1.12ASK(1)2ASK2ASK就是把频率、相位作为常量,而把振幅作为变量,信息比特是通过载波的幅度来传递的。由于调制信号只有0或1两个电平,相乘的结果相当于将载频或者关断,或者接通,它的实际意义是当调制的数字信号1时,传输载波;当调制的数字信号为0时,不传输载波。公式为:001,cos)(2kkcASKaatAts当,当1.22FSK2FSK可以看做是2个不同频率的2ASK的叠加,其调制与解调方法与2ASK差不多,主要频率F1和F2,不同的组合产生所要求的2FSK调制信号。公式如下:1.32PSK2PSK以载波的相位变化为基准,载波的相位随数字基带序列信号的1或者0而改变,通常用已经调制完的载波的0或者π表示数据1或者0,每种相位与之一0cos1,cos)(212kkFSKatAatAts当,当一对应。二.数字调制技术的仿真实现本课程设计需要借助MATLAB的M文件编程功能,对2ASK..2PSK.2FSK进行调制与解调的设计,并绘制出调制与解调后的波形,误码率的情况分析,软件仿真可在已有平台上实现。1.2ASK代码主函数closeallclearalln=16;fc=1000000;bitRate=1000000;N=50;%noise=ti;noise=10;signal=source(n,N);%生成二进制代码transmittedSignal=askModu(signal,bitRate,fc,N);%调制后信号signal1=gussian(transmittedSignal,noise);%加噪声configueSignal=demoASK(signal1,bitRate,fc,n,N);source代码functionsendSignal=source(n,N)sendSignal=randint(1,n)bit=[];fori=1:length(sendSignal)ifsendSignal(i)==0bit1=zeros(1,N);elsebit1=ones(1,N);endbit=[bit,bit1];endfigure(1)plot(1:length(bit),bit),title('transmittingofbinary'),gridon;axis([0,N*length(sendSignal),-2,2]);endaskModu代码functiontransmittedSignal=askModu(signal,bitRate,fc,N)%signal为输入信号,bitrate为bit速率,fc调制信号频率,N%signal=[00101101];%bitRate=1000000;%fc=1000000;%N=32;t=linspace(0,1/bitRate,N);c=sin(2*pi*t*fc);transmittedSignal=[];fori=1:length(signal)transmittedSignal=[transmittedSignal,signal(i)*c];endfigure(2)%画调制图plot(1:length(transmittedSignal),transmittedSignal);title('ModulationofASK');gridon;figure(3)%画频谱实部m=0:length(transmittedSignal)-1;F=fft(transmittedSignal);plot(m,abs(real(F))),title('ASK_frequency-domainanalysisreal');gridon;%figure(4)画频谱虚部%plot(m,imag(F));title('ASK_frequency-domainanalysisimag');%gridon;endCheckRatePe代码functionPeWrong=CheckRatePe(signal1,signal2,s)rights=0;wrongs=0;forki=1:s-2if(signal1(ki)==signal2(ki))rights=rights+1;elsewrongs=wrongs+1;endendPeWrong=wrongs/(wrongs+rights);enddemoASK代码functionbitstream=demoASK(receivedSignal,bitRate,fc,n,N)loadnumsignal1=receivedSignal;signal2=abs(signal1);%ÕûÁ÷signal3=filter(num1,1,signal2);%LPF,°üÂç¼ì²¨IN=fix(length(num1)/2);%ÑÓ³Ùʱ¼äbitstream=[];LL=fc/bitRate*N;i=IN+LL/2;while(i=length(signal3))%Åоöbitstream=[bitstream,signal3(i)=0.5];i=i+LL;endfigure(6)subplot(3,1,1);%接收波形plot(1:length(signal1),signal1);title('Waveofreceivingterminal(includingnoise)');gridon;subplot(3,1,2);%接收整流后波形plot(1:length(signal2),signal2);title('Waveofcommutate');gridon;subplot(3,1,3);%包络检波波形plot(1:length(signal3),signal3);title('WaveofLPF');gridon;bit=[];fori=1:length(bitstream)ifbitstream(i)==0bit1=zeros(1,N);elsebit1=ones(1,N);endbit=[bit,bit1];endfigure(7)%解调后的二进制波形plot(bit),title('binaryofreceivingterminal'),gridon;axis([0,N*length(bitstream),-2.5,2.5]);endgussian代码%加高斯白噪声functionsignal=gussian(transmittedSignal,noise)signal=sqrt(2)*transmittedSignal;signal=awgn(signal,noise);figure(5)plot(1:length(signal),signal);title('Waveincludingnoise'),gridon;end/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////fsk主函数代码closeallclearalln=16;%二进制代码长度f1=18000000;%频率1f2=6000000;%频率2bitRate=1000000;%bit速率N=50;%码元宽度%noise=ti;noise=10;%家性噪声大小signal=source(n,N);%产生二进制代码transmittedSignal=fskModu(signal,bitRate,f1,f2,N);%调制signal1=gussian(transmittedSignal,noise);%加噪声configueSignal=demoFSK(signal1,bitRate,f1,f2,N);%解调source代码%二进制信号产生函数functionsendSignal=source(n,N)sendSignal=randint(1,n)bit=[];fori=1:length(sendSignal)ifsendSignal(i)==0bit1=zeros(1,N);elsebit1=ones(1,N);endbit=[bit,bit1];endfigure(1)plot(bit),title('transmittingofbinary'),gridon;axis([0,N*length(sendSignal),-2.5,2.5]);endfskModu代码%频率调制函数functiontransmittedSignal=fskModu(signal,bitRate,f1,f2,N)t=linspace(0,1/bitRate,N);c1=sin(2*pi*t*f1);%调制信号1c2=sin(2*pi*t*f2);%调制信号2transmittedSignal=[];fori=1:length(signal)%调制ifsignal(i)==1transmittedSignal=[transmittedSignal,c1];elsetransmittedSignal=[transmittedSignal,c2];endendfigure(2)%画调制后波形图plot(1:length(transmittedSignal),transmittedSignal);title('ModulationofFSK');gridon;figure(3)%画调制后频谱图m=0:length(transmittedSignal)-1;F=fft(transmittedSignal);plot(m,abs(real(F))),title('ASK_frequency-domainanalysisreal');gridon;enddemoFSK代码functionbitstream=demoFSK(receivedSignal,bitRate,f1,f2,N)loadnumsignal1=receivedSignal;signal2=filter(gaotong,1,signal1);%通过HPF,得到高通分量signal3=abs(signal2);%整流signal3=filter(lowpass,1,signal3);%通过低通,形成包络bitstream=[];IN1=fix(length(lowpass)/2)+fix(length(gaotong)/2);%延迟时间bitstream1=[];LL=N;%每个bit的抽样点数i=IN1+LL/2;while(i=length(signal3))%判决bitstream1=[bitstream1,signal3(i)=0.5];i=i+LL;endbitstream1figure(5)subplot(3,1,1);plot(1:length(signal1),signal1);title('Waveofreceivingterminal(includingnoise)');gridon;subplot(3,1,2);