qpsk瑞利matlab
- 格式:doc
- 大小:31.00 KB
- 文档页数:4
%%%%qpsk simulation实现QPSK瑞丽信道的各部分图
%***********************初始设置********************************
sr=2560; %码符号率,单位symbol/s
ml=2; %调制等级,对于qpsk是2
br=sr.*ml; %比特率,单位bit/s
nd=20; %码符号数目
ebn0=20; %比特能量,单位db
IPIONT=8; %过采样数目
bit_time=1/sr/ml;%比特持续时间
%***********************升余弦滤波器及信道初始化设置*****************************
irfn=21;%抽点数目
alfas=0.5; %滚降因子
[xh]=hrollfcoef(irfn,IPIONT,sr,alfas,1);%发送端根升余弦系统
[xh2]=hrollfcoef(irfn,IPIONT,sr,alfas,0);%接受端根升余弦系统
tstp=1/sr/IPIONT; %最小时间间隔
itau = [0];
dlvl = [0];
no=6;%产生单条瑞利信道的需要的不可分辨多径数
th1=[0.0];
itnd0=nd*IPIONT*100;
itnd1=[1000];
now1=1;
fd=160;%最大多普勒频移,单位HZ
flat =1;%1表示仅考虑幅度,0表示幅度和相位都受到衰落
%***********************产生二进制比特流********************************* %% 产生二进制比特流
data=rand(1,nd*ml)>0.5;
%% qpsk调制
[ich,qch]=qpskmod(data,1,nd,ml);
figure(1);
subplot 311;stairs (data) ,title('码元');axis([0,nd*ml,-2,2]);
subplot 312;stairs (ich) ,title('同向支路I');axis([0,nd,-2,2]);
subplot 313;stairs (qch) ,title('正交支路Q');axis([0,nd,-2,2]);
%**********************脉冲成型滤波器*********************************
%% *脉冲成型滤波器
fs=sr*10; % 采样频率
[ich1,qch1]=comoversamp(ich,qch,length(ich),IPIONT);%过采样
data1=ich1+qch1;
%% 根升余弦滤波
[ich2,qch2]=comconv(ich1,qch1,xh);
data2=ich2+qch2;
figure(2);
subplot 311; plot(data2); title('发送端采用升余弦波形传输的原始数据');grid on;
subplot 312; plot(ich2); title('发送端采用升余弦波形传输的同相支路');grid on;
subplot 313; plot(qch2); title('发送端采用升余弦波形传输的正交支路');grid on;
h = spectrum.welch;
figure; psd(h,data2,'fs',fs);
title('基带升余弦波形传输信号功率谱密度'); xlabel('频率(MHz) ');
%***********************qpsk 载波调制**********************************
fc=40*sr; % 载波频率Hz 是符号速率的40倍
ich3=ich2.*cos(2*pi*fc*tstp*(1:length(ich2)));%乘以载波
qch3=qch2.*(-sin(2*pi*fc*tstp*(1:length(qch2))));
data3=ich3+qch3;
figure(3);
subplot 311;plot (data3) ,title('调制后波形');
subplot 312;plot (ich3) ,title('调制后I路波形');
subplot 313;plot (qch3) ,title('调制后Q路波形');
h = spectrum.welch;
figure(4);
psd(h,data3,'fs',fs);
title('经过载波调制后接收端信号功率谱密度'); xlabel('频率(MHz) ');
%***********************加性白噪声计算***************************
spow=sum(ich2.*ich2+qch2.*qch2)/nd;
attn=0.5*spow*sr/br*10^(-ebn0/10);
attn=sqrt(attn);
%*********************** 经过Rayleigh信道传输*********************************
counter=1000;%衰落计数器
[ich41,qch41,ramp,rcos,rsin]=fade(ich3,qch3,length(ich3),tstp,fd,no,counter,flat);%经过瑞利信道传输
[ich4,qch4]=comb(ich41,qch41,attn); %经过高斯信道传输
data4=ich4+qch4;
figure(5);
subplot 211; plot (data3) ,title('调制后波形');
subplot 212; plot (data4) ,title('经过Rayleigh信道后波形');
h = spectrum.welch;
figure(6);
psd(h,data4,'fs',fs);
title('经过Rayleigh信道后接收端信号功率谱密度'); xlabel('频率(MHz) ');
%% 解调
Idem=ich4.*cos(2*pi*fc*tstp*(1:length(ich4)));%相干解调
Qdem=qch4.*(-sin(2*pi*fc*tstp*(1:length(qch4))));
%*********************** 根升余弦滤波***************************** %% 根升余弦滤波,低通滤波器
[ich5,qch5]=comconv(Idem,Qdem,xh2);
ich5=ich5.*2;
qch5=qch5.*2;
data5=ich5+qch5;
figure(7);
subplot 311;plot (data5) ,title('低通滤波后波形');
subplot 312;plot (ich5) ,title('低通滤波后I路波形');
subplot 313;plot (qch5) ,title('低通滤波后Q路波形');
syncpoint=irfn*IPIONT+1;
ich6=ich5(syncpoint:IPIONT:length(ich5)-syncpoint);
qch6=qch5(syncpoint:IPIONT:length(qch5)-syncpoint);
figure(8);
title('Demod')
subplot 211;stairs(ich6) ,title('抽样后I码元'),axis([0,length(ich6),-3,3]);
subplot 212;stairs(qch6) ,title('抽样后Q码元'),axis([0,length(ich6),-3,3]);
%% 解码
demodata=zeros(1,nd*m1);
demodata(1,(1:m1:nd*m1-1))=ich6(1,(1:nd))>=0;
demodata(1,(2:m1:nd*m1))=qch6(1,(1:nd))>=0;
figure;
title('Demod')
subplot 211;stairs (demodata) ,title('解码后码元'),axis([0,nd*m1,-2,2]);
subplot 212;stairs (data) ,title('原始二进制码元'),axis([0,nd*m1,-2,2]);
%% 星座图
figure;
title('星座图')
plot(idata+j*qdata,'b*');grid on;axis([-3 ,3 ,-3 ,3]);
hold on;
plot(ich6+j*qch6,'r*');axis([-3 ,3 ,-3 ,3]);
legend('经过瑞利信道前星座图','经过瑞利信道后星座图');。