📄 qpsk.m
字号:
%******************modulation**************************
D=[1 0 1 1 0 0 1 0 ];
N=length(D);%基带信号符号数目
t=0:2*pi/99:4.04*pi;
x=ones(1,200);
d0=[];d1=[];
e0=[];e1=[];
%---------转化的四个相位,分别对应00,10,11,01
o1=pi/4;
o2=3*pi/4;
o3=5*pi/4;
o4=7*pi/4;
%---------将二进制转化为四进制,c0表示正交支路,c1表示同相支路
for i=1:2:N,
if D(i)==0&D(i+1)==0;
c0=cos(o1)*x;
c1=sin(o1)*x;
elseif D(i)==1&D(i+1)==0;
c0=cos(o2)*x;
c1=sin(o2)*x;
elseif D(i)==1&D(i+1)==1;
c0=cos(o3)*x;
c1=sin(o3)*x;
elseif D(i)==0&D(i+1)==1;
c0=cos(o4)*x;
c1=sin(o4)*x;
end
c=cos(t);
s=sin(t);
d0=[d0 c0];
d1=[d1 c1];
e0=[e0 c];
e1=[e1 s];
end
%*******QPSK的表达式*******
I=d0.*e0;
Q=d1.*e1;
qpsk=I+Q;
%**************demodulation********************
msg1=I.*e0;
msg2=Q.*e1;
ch_I=find(msg1>0);
demo_I(ch_I)=0;
ch_I=find(msg1<0);
demo_I(ch_I)=1;
ch_Q=find(msg2>0);
demo_Q(ch_Q)=0;
ch_Q=find(msg2<0);
demo_Q(ch_Q)=1;
%----串并变换
j=100;%定点抽样
for i=1:2:N-1,
demo(i)=demo_I(j);
demo(i+1)=demo_Q(j);
j=j+200;
if j>700,break
end
end
%----仅仅为了便于观察
K=[];
for k=1:N,
K=[K,demo(k).*ones(1,100)];
end
%*****************drawing**********************
subplot(2,1,1);plot(qpsk);title('QPSK modulation');grid;
subplot(2,1,2);plot(K);title('QPSK demodulation');grid;axis([0,800,-2,2])
xlabel('1 0 1 1 0 0 1 0')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -