MATLAB代码
% pi/4-DQPSK modulation
%输入一串数,输出经过差分并映射的I、Q两路数据
function [I,Q]=pi4_dqpskmod(data)
n=length(data)./2;
data1=data.*2-1;
Idata=zeros(1,n);
Qdata=zeros(1,n);
Idata=data1(1,1:2:2*n); %串并变换
Qdata=data1(1,2:2:2*n);
I(1)=Qdata(1)*-0.5.^(0.5); %差分编码并映射到星座图
Q(1)=Idata(1)*-0.5.^(0.5);
for i=2:n
I(i)=(I(i-1)*Qdata(i)-Q(i-1)*Idata(i))*-0.5.^(0.5);
Q(i)=(I(i-1)*Idata(i)+Q(i-1)*Qdata(i))*-0.5.^(0.5);
end
% pi/4-DQPSK demodulation
% 输入I、Q两路数,输出一路解调后的数
function [data]=pi4_dqpskdemod(I,Q) %差分解调
x(1)=I(1);
y(1)=Q(1);
if (x(1)>0)
Qdata(1)=0;
else
Qdata(1)=1;
end
if (y(1)>0)
Idata(1)=0;
else
Idata(1)=1;
end
for i=2:length(I)
x(i)=I(i)*I(i-1)+Q(i)*Q(i-1);
if (x(i)>0)
Qdata(i)=0;
else
Qdata(i)=1;
end
y(i)=Q(i)*I(i-1)-I(i)*Q(i-1);
if (y(i)>0)
Idata(i)=0;
else
Idata(i)=1;
end
end
data(1,1:2:2*length(I))=Idata(1,1:length(I)); %并串变换
data(1,2:2:2*length(I))=Qdata(1,1:length(I));