基于matlab的QPSK与BPSK信号性能比较仿真

┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ 装 ┊ ┊ ┊ ┊ ┊ 订 ┊ ┊ ┊ ┊ ┊ 线 ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊

pe1=q(d1/sigma1)+q(d2/sigma1); pe2=q(d3/sigma)+q(d4/sigma); peideal(m)=peideal(m)+pe1; pesystem(m)=pesystem(m)+pe2; end end

peideal=(1/2)*peideal./nx; pesystem=(1/2)*pesystem./nx; return

function QPSKThreeray(p0,p1,p2,delay)

NN=256; %发送的信号数 tb=0.5; %信号周期

fs=16; %每信号的采样数 ebn0db=[1:2:14]; %信噪比矢量 %产生QPSK信号

x=random_binary(NN,fs)+i*random_binary(NN,fs);

delay0=0; delay1=0; delay2=delay;

%设置瑞利信道

gain1=sqrt(p1)*abs(randn(1,NN)+i*randn(1,NN)); gain2=sqrt(p2)*abs(randn(1,NN)+i*randn(1,NN));

for k=1:NN for kk=1:fs

index=(k-1)*fs+kk;

ggain1(1,index)=gain1(1,k); ggain2(1,index)=gain2(1,k); end end y1=x;

for k=1:delay2

y2(1,k)=y1(1,k)*sqrt(p0); end

for k=(delay2+1):(NN*fs)

y2(1,k)=y1(1,k)*sqrt(p0)+y1(1,k-delay1)*ggain1(1,k)+y1(1,k-delay2)*ggain2(1,k); end

%匹配滤波器 b=-ones(1,fs); b=b/fs; a=1;

y=filter(b,a,y2);

%应用半解析方法,进行误码率估计。 [cor lags]=vxcorr(x,y); cmax=max(max(abs(cor))); nmax=find(abs(cor)==cmax); timelag=lags(nmax); corrmag=cmax;

theta=angle(cor(nmax)); y=y*exp(-i*theta);

hh=impz(b,a); ts=1/fs;

nbw=(fs/2)*sum(hh.^2);

index=(10*fs+8:fs:(NN-10)*fs+8); xx=x(index);

yy=y(index-timelag+1); [n1 n2]=size(y2);

┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ 装 ┊ ┊ ┊ ┊ ┊ 订 ┊ ┊ ┊ ┊ ┊ 线 ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊

ny2=n1*n2;

eb=tb*sum(sum(abs(y2).^2))/ny2; eb=eb/2;

[peideal,pesystem]=qpsk_berest(xx,yy,ebn0db,eb,tb,nbw); figure

semilogy(ebn0db,peideal,'b*-',ebn0db,pesystem,'r+-') xlabel('E_b/N_0');

ylabel('Probability of Error'); grid

axis([0 14 10^(-10) 1]) return

代码4

function bpskThreeray(p0,p1,p2,delay)

NN=256; tb=0.5; fs=16;

ebn0db=[1:2:14];

x=random_binary(NN,fs);

delay0=0; delay1=0; delay2=delay;

gain1=sqrt(p1)*abs(randn(1,NN)+i*randn(1,NN)); gain2=sqrt(p2)*abs(randn(1,NN)+i*randn(1,NN));

for k=1:NN for kk=1:fs

index=(k-1)*fs+kk;

ggain1(1,index)=gain1(1,k); ggain2(1,index)=gain2(1,k); end end y1=x;

for k=1:delay2

y2(1,k)=y1(1,k)*sqrt(p0); end

for k=(delay2+1):(NN*fs)

y2(1,k)=y1(1,k)*sqrt(p0)+y1(1,k-delay1)*ggain1(1,k)+y1(1,k-delay2)*ggain2(1,k); end

b=-ones(1,fs); b=b/fs; a=1;

y=filter(b,a,y2);

[cor lags]=vxcorr(x,y); cmax=max(max(abs(cor))); nmax=find(abs(cor)==cmax); timelag=lags(nmax); corrmag=cmax;

theta=angle(cor(nmax)); y=y*exp(-i*theta);

hh=impz(b,a); ts=1/fs;

nbw=(fs/2)*sum(hh.^2);

┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ 装 ┊ ┊ ┊ ┊ ┊ 订 ┊ ┊ ┊ ┊ ┊ 线 ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊ ┊

index=(10*fs+8:fs:(NN-10)*fs+8); xx=x(index);

yy=y(index-timelag+1); [n1 n2]=size(y2); ny2=n1*n2;

eb=tb*sum(sum(abs(y2).^2))/ny2; eb=eb/2;

[peideal,pesystem]=qpsk_berest(xx,yy,ebn0db,eb,tb,nbw); figure

semilogy(ebn0db,peideal,'b*-',ebn0db,pesystem,'r+-') xlabel('E_b/N_0');

ylabel('Probability of Error'); grid

axis([0 14 10^(-10) 1]) return

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4