姓名:NikeyMATLAB环境下环境下环境下环境下16QAM调制及解调仿真调制及解调仿真调制及解调仿真调制及解调仿真程序说明程序说明程序说明程序说明一、正交调制及相干解调原理框图正交调制原理框图相干解调原理框图二、MQAM调制介绍及本仿真程序的几点说明MQAM可以用正交调制的方法产生,本仿真中取M=16,即幅度和相位相结合的16个信号点的调制。为了观察信道噪声对该调制方式的影响,我们在已调信号中又加入了不同强度的高斯白噪声,并统计其译码误码率。为了简化程序和得到可靠的误码率,我们在解调时并未从已调信号中恢复载波,而是直接产生与调制时一模一样的载波来进行信号解调。三、仿真结果图附源程序代码:main_plot.mclear;clc;echooff;closeall;N=10000;%设定码元数量fb=1;%基带信号频率fs=32;%抽样频率fc=4;%载波频率,为便于观察已调信号,我们把载波频率设的较低Kbase=2;%Kbase=1,不经基带成形滤波,直接调制;%Kbase=2,基带经成形滤波器滤波后,再进行调制info=random_binary(N;%产生二进制信号序列[y,I,Q]=qam(info,Kbase,fs,fb,fc;%对基带信号进行16QAM调制y1=y;y2=y;%备份信号,供后续仿真用T=length(info/fb;m=fs/fb;nn=length(info;dt=1/fs;t=0:dt:T-dt;subplot(211;%便于观察,这里显示的已调信号及其频谱均为无噪声干扰的理想情况%由于测试信号码元数量为10000个,在这里我们只显示其总数的1/10plot(t(1:1000,y(1:1000,t(1:1000,I(1:1000,t(1:1000,Q(1:1000,[035],[00],'b:';title('已调信号(In:red,Qn:green';%傅里叶变换,求出已调信号的频谱n=length(y;y=fft(y/n;y=abs(y(1:fix(n/2*2;q=find(y1e-04;y(q=1e-04;y=20*log10(y;f1=m/n;f=0:f1:(length(y-1*f1;subplot(223;plot(f,y,'r';gridon;title('已调信号频谱';xlabel('f/fb';%画出16QAM调制方式对应的星座图subplot(224;constel(y1,fs,fb,fc;title('星座图';SNR_in_dB=8:2:24;%AWGN信道信噪比forj=1:length(SNR_in_dBy_add_noise=awgn(y2,SNR_in_dB(j;%加入不同强度的高斯白噪声y_output=qamdet(y_add_noise,fs,fb,fc;%对已调信号进行解调numoferr=0;fori=1:Nif(y_output(i~=info(i,numoferr=numoferr+1;end;end;Pe(j=numoferr/N;%统计误码率end;figure;semilogy(SNR_in_dB,Pe,'red*-';gridon;xlabel('SNRindB';ylabel('Pe';title('16QAM调制在不同信道噪声强度下的误码率';random_binary.m%产生二进制信源随机序列function[info]=random_binary(Nifnargin==0,%如果没有输入参数,则指定信息序列为10000个码元N=10000;end;fori=1:N,temp=rand;if(temp0.5,info(i=0;%1/2的概率输出为0elseinfo(i=1;%1/2的概率输出为1endend;qam.mfunction[y,I,Q]=qam(x,Kbase,fs,fb,fc;%T=length(x/fb;m=fs/fb;nn=length(x;dt=1/fs;t=0:dt:T-dt;%串/并变换分离出I分量、Q分量,然后再分别进行电平映射I=x(1:2:nn-1;[I,In]=two2four(I,4*m;Q=x(2:2:nn;[Q,Qn]=two2four(Q,4*m;ifKbase==2;%基带成形滤波I=bshape(I,fs,fb/4;Q=bshape(Q,fs,fb/4;end;y=I.*cos(2*pi*fc*t-Q.*sin(2*pi*fc*t;%调制qamdet.m%QAM信号解调function[xn,x]=qamdet(y,fs,fb,fc;dt=1/fs;t=0:dt:(length(y-1*dt;I=y.*cos(2*pi*fc*t;Q=-y.*sin(2*pi*fc*t;[b,a]=butter(2,2*fb/fs;%设计巴特沃斯滤波器I=filtfilt(b,a,I;Q=filtfilt(b,a,Q;m=4*fs/fb;N=length(y/m;n=(.6:1:N*m;n=fix(n;In=I(n;Qn=Q(n;xn=four2two([InQn];%I分量Q分量并/串转换,最终恢复成码元序列xnnn=length(xn;xn=[xn(1:nn/2;xn(nn/2+1:nn];xn=xn(:;xn=xn';bshape.m%基带升余弦成形滤波器functiony=bshape(x,fs,fb,N,alfa,delay;%设置默认参数ifnargin6;delay=8;end;ifnargin5;alfa=0.5;end;ifnargin4;N=16;end;b=firrcos(N,fb,2*alfa*fb,fs;y=filter(b,1,x;two2four.m%二进制转换成四进制function[y,yn]=two2four(x,m;T=[01;32];n=length(x;ii=1;fori=1:2:n-1;xi=x(i:i+1+1;yn(ii=T(xi(1,xi(2;ii=ii+1;end;yn=yn-1.5;y=yn;fori=1:m-1;y=[y;yn];end;y=y(:';%映射电平分别为-1.5;0.5;0.5;1.5four2two.m%四进制转换成二进制functionxn=four2two(yn;y=yn;ymin=min(y;ymax=max(y;ymax=max([ymaxabs(ymin];ymin=-abs(ymax;yn=(y-ymin*3/(ymax-ymin;%设置门限电平,判决I0=find(yn0.5;yn(I0=zeros(size(I0;I1=find(yn=0.5&yn1.5;yn(I1=ones(size(I1;I2=find(yn=1.5&yn2.5;yn(I2=ones(size(I2*2;I3=find(yn=2.5;yn(I3=ones(size(I3*3;%一位四进制码元转换为两位二进制码元T=[00;01;11;10];n=length(yn;fori=1:n;xn(i,:=T(yn(i+1,:;end;xn=xn';xn=xn(:;xn=xn';constel.m%画出星座图functionc=constel(x,fs,fb,fc;N=length(x;m=2*fs/fb;n=fs/fc;i1=m-n;i=1;ph0=(i1-1*2*pi/n;whilei=N/m;xi=x(i1:i1+n-1;y=2*fft(xi/n;c(i=y(2;i=i+1;i1=i1+m;end;%如果无输出,则作图ifnargout1;cmax=max(abs(c;ph=(0:5:360*pi/180;plot(1.414*cos(ph,1.414*sin(ph,'c';holdon;fori=1:length(c;ph=ph0-angle(c(i;a=abs(c(i/cmax*1.414;plot(a*cos(ph,a*sin(ph,'r*';end;plot([-1.51.5],[00],'k:',[00],[-1.51.5],'k:';holdoff;axisequal;axis([-1.51.5-1.51.5];end;