基于某MATLAB仿真的数字信号调制的性能比较和分析报告.doc
word2ASK、2FSK、2PSK数字调制系统的Matlab实现与性能分析比拟引言:数字信号有两种传输方式,分别是基带传输方式和调制传输方式,即带通,在实际应用中,因基带信号含有大量低频分量不利于传送,所以必须经过载波和调制形成带通信号,通过数字基带信号对载波某些参量进展控制,使之随机带信号的变化而变化,这这一过程即为数字调制。数字调制为信号长距离高效传输提供保障,现已广泛应用于生活和生产中。另外根据控制载波参量方式的不同,数字调制主要有调幅ASK,调频(FSK),调相(PSK)三种根本形式。本次课题针对于二进制的2ASK、2FSK、2PSK进展讨论,应用Matlab矩阵实验室进展仿真,分析和修改,通过仿真系统生成一个人机交互界面,以利于仿真系统的操作。通过对系统的仿真,更加直观的了解数字调制系统的性能与影响其性能的各种因素,以便于比拟,评论和改良。 关键词:数字,载波,调制,2ASK,2FSK,2PSK,Matlab,仿真,性能,比拟,分析正文:一.数字调制与解调原理1.1 2ASK12ASK2ASK就是把频率、相位作为常量,而把振幅作为变量,信息比特是通过载波的幅度来传递的。由于调制信号只有0或1两个电平,相乘的结果相当于将载频或者关断,或者接通,它的实际意义是当调制的数字信号"1时,传输载波;当调制的数字信号为"0"时,不传输载波。表达式为:1.2 2FSK2FSK可以看做是2个不同频率的2ASK的叠加,其调制与解调方法与2ASK差不多,主要频率F1和F2,不同的组合产生所要求的2FSK调制信号。公式如下:1.3 2PSK2PSK以载波的相位变化为基准,载波的相位随数字基带序列信号的1或者0而改变,通常用已经调制完的载波的0或者表示数据1或者0,每种相位与之一一对应。二数字调制技术的仿真实现本课程设计需要借助MATLAB的M文件编程功能,对2ASK.2PSK.2FSK进展调制与解调的设计,并绘制出调制与解调后的波形,误码率的情况分析,软件仿真可在已有平台上实现。1.2ASK代码主函数close allclear alln=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代码function sendSignal=source(n,N) sendSignal=randint(1,n) bit=;for i=1:length(sendSignal) if sendSignal(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(1) plot(1:length(bit),bit),title('transmitting of binary'),grid on; axis(0,N*length(sendSignal),-2,2);endaskModu代码function transmittedSignal=askModu(signal,bitRate,fc,N)%signal为输入信号,bitrate为bit速率,fc调制信号频率,N %signal=0 0 1 0 1 1 0 1;% bitRate=1000000;% fc=1000000;% N=32; t=linspace(0,1/bitRate,N); c=sin(2*pi*t*fc); transmittedSignal=;for i=1:length(signal) transmittedSignal=transmittedSignal,signal(i)*c;endfigure(2) %画调制图plot(1:length(transmittedSignal),transmittedSignal);title('Modulation of ASK');grid on;figure(3)%画频谱实部m=0:length(transmittedSignal)-1;F=fft(transmittedSignal);plot(m,abs(real(F),title('ASK_frequency-domain analysis real');grid on;%figure(4)画频谱虚部%plot(m,imag(F);title('ASK_frequency-domain analysis imag');%grid on;endCheckRatePe代码function PeWrong=CheckRatePe(signal1,signal2,s)rights=0;wrongs=0;for ki=1:s-2if(signal1(ki)=signal2(ki) rights=rights+1;else wrongs=wrongs+1;endendPeWrong=wrongs/(wrongs+rights);enddemoASK代码function bitstream=demoASK(receivedSignal,bitRate,fc,n,N) load num signal1=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;end figure(6) subplot(3,1,1);%接收波形 plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2);%接收整流后波形 plot(1:length(signal2),signal2);title('Wave of mutate');grid on; subplot(3,1,3);%包络检波波形 plot(1:length(signal3),signal3);title('Wave of LPF');grid on; bit=;for i=1:length(bitstream)if bitstream(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(7)%解调后的二进制波形 plot(bit),title('binary of receiving terminal'),grid on; axis(0,N*length(bitstream),-2.5,2.5);endgussian代码 %加高斯白噪声function signal=gussian(transmittedSignal,noise) signal=sqrt(2)*transmittedSignal; signal=awgn(signal,noise); figure(5) plot(1:length(signal),signal); title('Wave including noise'),grid on;endfsk主函数代码close allclear alln=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代码%二进制信号产生函数function sendSignal=source(n,N) sendSignal=randint(1,n) bit=;for i=1:length(sendSignal)if sendSignal(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(1) plot(bit),title('transmitting of binary'),grid on; axis(0,N*length(sendSignal),-2.5,2.5);endfskModu代码%频率调制函数function transmittedSignal=fskModu(signal,bitRate,f1,f2,N) t=linspace(0,1/bitRate,N); c1=sin(2*pi*t*f1);%调制信号1 c2=sin(2*pi*t*f2);%调制信号2 transmittedSignal=;for i=1:length(signal)%调制if signal(i)=1 transmittedSignal=transmittedSignal,c1;else transmittedSignal=transmittedSignal,c2;endendfigure(2)%画调制后波形图plot(1:length(transmittedSignal),transmittedSignal);title('Modulation of FSK');grid on;figure(3) %画调制后频谱图m=0:length(transmittedSignal)-1;F=fft(transmittedSignal);plot(m,abs(real(F),title('ASK_frequency-domain analysis real');grid on;enddemoFSK代码function bitstream=demoFSK(receivedSignal,bitRate,f1,f2,N) load num signal1=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;end bitstream1 figure(5) subplot(3,1,1); plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2); plot(1:length(signal2),signal2);title('After Passing HPF');grid on; subplot(3,1,3); plot(1:length(signal3),signal3);title('After Passing LPF');grid on; signal4=filter(daitong,1,signal1); %通过BPF得到低频分量 signal5=abs(signal4); %整流 signal5=filter(lowpass,1,signal5); %通过LPF,形成包络 IN2=fix(length(lowpass)/2)+fix(length(daitong)/2); %延迟时间 bitstream2=; LL=N; %每个bit的的抽样点数 i=IN2 +LL/2;while (i<=length(signal5) %判决 bitstream2=bitstream2,signal5(i)>=0.5; i=i+LL;end bitstream2 figure(6) subplot(3,1,1); plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2); plot(1:length(signal4),signal4);title('After Passing BPF');grid on; subplot(3,1,3); plot(1:length(signal5),signal5);title('After Passing LPF');grid on;for i=1:min(length(bitstream1),length(bitstream2) %判决if(bitstream1(i)>bitstream2(i) bitstream(i)=1;else bitstream(i)=0;endend bitstream bit=; %接收端波形for i=1:length(bitstream)if bitstream(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(7) plot(bit),title('binary of receiving terminal'),grid on; axis(0,N*length(bitstream),-2.5,2.5); endCheckRatePe代码function PeWrong=CheckRatePe(signal1,signal2,s)rights=0;wrongs=0;for ki=1:s-2if(signal1(ki)=signal2(ki) rights=rights+1;else wrongs=wrongs+1;endendPeWrong=wrongs/(wrongs+rights);endgussian代码function signal=gussian(transmittedSignal,noise) signal=sqrt(2)*transmittedSignal; signal=awgn(signal,noise); figure(4) plot(1:length(signal),signal),title('Adding Noise'); grid on;end2psk主函数代码close allclear alln=16;%二进制码长fc=1000000;%载波频率bitRate=1000000;信息频率N=50;%码宽noise=10;%信道加性噪声大小signal=source(n,N);生成二进制代码transmittedSignal=bpskModu(signal,bitRate,fc,N);对信号进展调制并进展频谱分析signal1=gussian(transmittedSignal,noise)%加信道噪声configueSignal=demoBPSK(signal1,bitRate,fc,n,N);%信号解调source代码function sendSignal=source(n,N) sendSignal=randint(1,n) bit=;for i=1:length(sendSignal)if sendSignal(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(1) plot(bit),title('transmitting of binary'),grid on; axis(0,N*length(sendSignal),-2.5,2.5);endbpskModu代码function transmittedSignal=bpskModu(signal,bitRate,fc,N) t=linspace(0,1/bitRate,N); c1=sin(2*pi*t*fc); c2=sin(2*pi*t*fc + pi); transmittedSignal=;for i=1:length(signal)if signal(i)=1 transmittedSignal=transmittedSignal,c1;else transmittedSignal=transmittedSignal,c2;endendfigure(2) %画调制图plot(1:length(transmittedSignal),transmittedSignal);title('Modulation of BPSK');grid on;figure(3)%画频谱图m=0:length(transmittedSignal)-1;F=fft(transmittedSignal);plot(m,abs(real(F),title('BPSK_frequency-domain analysis real');grid on;endCheckRatePe代码function PeWrong=CheckRatePe(signal1,signal2,s)rights=0;wrongs=0;for ki=1:s-2if(signal1(ki)=signal2(ki) rights=rights+1;else wrongs=wrongs+1;endendPeWrong=wrongs/(wrongs+rights);enddemoBPSK代码function bitstream=demoBPSK(receivedSignal,bitRate,fc,n,N) load num%读取num存储的低通滤波用的数据 signal1=receivedSignal; t=linspace(0,1/bitRate,N); c=sin(2*pi*t*fc); signal=;for i=1:n signal=signal,c;end signal2=signal1.*signal; %乘同频同相sin signal3=filter(num1,1,signal2); %LPF,包络检波3 IN=fix(length(num1)/2); %Ñ延迟时间 bitstream=; LL=fc/bitRate*N; i=IN+LL/2;while (i<=length(signal3) %判决 bitstream=bitstream,signal3(i)>=0; i=i+LL;end figure(5) subplot(3,1,1);%画接收的包含噪声的波形 plot(1:length(signal1),signal1);title('Wave of receiving terminal(including noise)');grid on; subplot(3,1,2);%相干解调波形 plot(1:length(signal2),signal2);title('After Multipling sin Fuction');grid on; subplot(3,1,3);%包络检波波形 plot(1:length(signal3),signal3);title('Wave of LPF');grid on; bit=;for i=1:length(bitstream)if bitstream(i)=0 bit1=zeros(1,N);else bit1=ones(1,N);end bit=bit,bit1;end figure(6)二进制接收信号波形 plot(bit);title('binary of receiving terminal');grid on; axis(0,N*length(bitstream),-2.5,2.5);endgussian代码function signal=gussian(transmittedSignal,noise) signal=sqrt(2)*transmittedSignal; signal=awgn(signal,noise); figure(4) plot(1:length(signal),signal),grid on; title('Adding noise')end三种调制方式的性能比拟:load PeRate;load PeRatep;%补偿误差fpeask(15)=1e-3;fpefsk(9)=1e-3;fpepsk(24)=0.002;fpepsk(26)=1e-3;figure(1)semilogy(-6:length(fpeask)-7,fpeask,-6:length(fpefsk)-7,fpefsk,-30:length(fpepsk)-31,fpepsk),grid on;title('Analysis Of Bit Error Rate');legend('ASK','FSK','PSK');xlabel('r/dB');ylabel('Pe');figure(2)semilogy(-6:length(fpefsk)-7,fpeask);grid on;title('Bit Error Rate Of ASK');xlabel('r/dB');ylabel('PeASK');figure(3)semilogy(-6:length(fpefsk)-7,fpefsk);grid on;title('Bit Error Rate Of FSK');xlabel('r/dB');ylabel('PeFSK');figure(4)semilogy(-16:length(fpepsk)-17,fpepsk);grid on;title('Bit Error Rate Of PSK');axis(-16,10,1e-3,1);xlabel('r/dB');ylabel('PePSK');三程序与调制解调波形 2ASK波形1随机信号产生2ASK信号调制3信号噪声附加4承受信号解调5解调出的基带信号3.2FSK1随机信号产生2FSK信号调制3信号噪声附加4承受信号解调5解调出的基带信号1随机信号产生2FSK信号调制3信号噪声附加4承受信号解调5解调出的基带信号3.4误码率分析4性能比拟四.课程设计心得体会通过本次的课程设计受益匪浅,感触良多。首先是进一步加深了对于通信原理,信号与系统,matlab程序设计等课程的理解和认知,也形象地把书本上的知识联系到了实际的应用和生产,随着比拟与理解了2ASK,2PSK,2FSK的各种性能与优缺点,提高了自己分析和比拟问题的能力,拓宽了自己的思路,掌握了各种全面以与辩证的看待问题的眼光,也逐步认识到自己的不足并加以克制和改正,从而得出正确结论。更以后的课题研究奠定了坚实的根底。五.参考文献1通信原理第6版樊昌信 .国防工业2数字通信原理 黎洪松 电子系科技大学3MATLAB程序设计教程 卫国 中国水利水电4通信原理 晓峰 清华大学5数字处理与matlab仿真 雪英 电子工业6通信系统仿真 冯玉涛 国防工业7matlab通信工程仿真 德丰 机械工业8通信原理基于Matlab的计算机仿真 郭文彬 桑林 邮电大学9MATLAB通信工程仿真 德丰 机械工业24 / 24