您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 国内外标准规范 > 数字通信QAM调制及其MATLAB仿真程序
数字通信QAM调制及其MATLAB仿真程序1.%数字通信QAM仿真2.clear3.%产生基带符号流4.M=16;%进制16QAM5.N=40;%信源比特流长度,为保证对齐,选择是log2(M)的整倍数6.bitstream=zeros(1,N);7.symbolstream=zeros(1,N/log2(M));8.forn1=1:N9.bitstream(n1)=binornd(1,0.5,1,1);10.end11.%格雷码编码12.forn1=1:length(symbolstream)13.pack=[bitstream(4*(n1-1)+1)bitstream(4*(n1-1)+2)bitstream(4*(n1-1)+3)bitstream(4*(n1-1)+4)];14.ifpack==[0000]15.symbolstream(n1)=1+j;16.elseifpack==[0010]17.symbolstream(n1)=2+j;18.elseifpack==[0011]19.symbolstream(n1)=2+2j;20.elseifpack==[0001]21.symbolstream(n1)=1+2j;22.elseifpack==[0101]23.symbolstream(n1)=-1+2j;24.elseifpack==[0100]25.symbolstream(n1)=-1+j;26.elseifpack==[0111]27.symbolstream(n1)=-2+2j;28.elseifpack==[0110]29.symbolstream(n1)=-2+j;30.elseifpack==[1110]31.symbolstream(n1)=-2-j;32.elseifpack==[1111]33.symbolstream(n1)=-2-2j;34.elseifpack==[1101]35.symbolstream(n1)=-1-2j;36.elseifpack==[1100]37.symbolstream(n1)=-1-j;38.elseifpack==[1000]39.symbolstream(n1)=1-j;40.elseifpack==[1010]41.symbolstream(n1)=2-j;42.elseifpack==[1001]43.symbolstream(n1)=1-2j;44.elsesymbolstream(n1)=2-2j;45.end46.end47.figure(1)48.holdon49.forn1=-2:250.forn2=-2:251.if~((n1==0)|(n2==0))52.scatter(n1,n2);53.end54.end55.end56.axis([-33-33]);57.holdoff58.title('16QAM星座图');59.xlabel('同相支路')60.ylabel('正交支路')61.%产生载波62.fc=10;%载波频率63.fs=100;%采样频率64.T=1;%每符号持续时间65.N_samples=T*fs;%每符号内的采样点数66.t=0:T/N_samples:(T-T/N_samples);67.carrier=exp(j*2*pi*fc*t);68.%产生信号脉冲g(t)69.%gt=ones(1,length(carrier));70.gt=1-cos(2*pi*(1/T)*t);71.72.%生成调制信号S(t)73.St_complex=zeros(1,length(carrier)*length(symbolstream));74.forn1=1:length(symbolstream)75.St_complex((N_samples*(n1-1)+1):(N_samples*(n1-1)+N_samples))=(symbolstream(n1)*carrier).*gt;76.end77.figure(2)78.St_real=real(St_complex);79.plot(St_real)80.title('QAM仿真波形图载波10Hzg(t)为升余弦脉冲');81.xlabel('采样点')82.ylabel('幅度')83.%求出功率谱,这种功率谱不是按照公式直接计算的,而是对所产生的一段时间内的信号的采样点进行FFT所得到的84.spectrum=(real(fft(St_real,10*length(St_real)))).^2;85.S_spectrum=spectrum(1:length(spectrum)/2);86.figure(3)87.F=0:fs/(2*length(S_spectrum)):fs/2-fs/(2*length(S_spectrum));88.plot(F,10*log10(S_spectrum))89.axis([050-7060]);90.title('QAM信号功率谱密度')91.xlabel('频率/Hz')92.ylabel('功率')93.figure(4)94.index=400:1600;95.plot(F(index),10*log10(S_spectrum(index)));96.axis([416060]);97.title('QAM信号功率谱密度在载频附近的放大图')98.xlabel('频率/Hz')99.ylabel('功率')
本文标题:数字通信QAM调制及其MATLAB仿真程序
链接地址:https://www.777doc.com/doc-5262407 .html