📄 oqpsk.m
字号:
clear all
close all
x=[1 1 -1 -1 -1 1 1 1];
x1=x(1:2:8);
x2=x(2:2:8);
t=[-1:0.01:7-0.01];
tt=length(t);
xx1=ones(1,800);
for i=1:tt
if (t(i)>=-1 & t(i)<=1) | (t(i)>=5& t(i)<=7);
xx1(i)=1;
else xx1(i)=-1;
end
end
t1=[0:0.01:8-0.01];
t2=0:0.01:7-0.01;
t3=-1:0.01:7.1-0.01;
t4=0:0.01:8.1-0.01;
tt1=length(t1);
xx2=ones(1,800);
for i=1:tt1
if (t1(i)>=0 & t1(i)<=2) | (t1(i)>=4& t1(i)<=8);
xx2(i)=1;
else xx2(i)=-1;
end
end
% ddd=fft(xx1);
% ddd0=fft(xx2);
% subplot(2,1,1);plot(t1,ddd);
% subplot(2,1,2);plot(t1,ddd0);
f=0:0.1:1;
xrc=0.5+0.5*cos(pi*f);
y1=conv(xx1,xrc)/5.5;
y2=conv(xx2,xrc)/5.5;
% ddd1=fft(y1);
% ddd2=fft(y2);
% figure
% subplot(2,1,1);plot(t2,ddd1);
% subplot(2,1,2);plot(t2,ddd2);
n0=randn(size(t2));
f1=1;
i=xx1.*cos(2*pi*f1*t);
q=xx2.*sin(2*pi*f1*t1);
I=i(101:800);
Q=q(1:700);
OQPSK=sqrt(1/2).*I+sqrt(1/2).*Q;
OQPSK_n=(sqrt(1/2).*I+sqrt(1/2).*Q)+n0;
n1=randn(size(t2));
i_rc=y1.*cos(2*pi*f1*t3);
q_rc=y2.*sin(2*pi*f1*t4);
I_rc=i(101:800);
Q_rc=q(1:700);
OQPSK_rc=(sqrt(1/2).*I_rc+sqrt(1/2).*Q_rc);
OQPSK_rc_n1=(sqrt(1/2).*I_rc+sqrt(1/2).*Q_rc)+n1;
figure(1)
subplot(6,1,1);plot(t3,i_rc);axis([-1 8 -1 1]);
subplot(6,1,2);plot(t4,q_rc);axis([-1 8 -1 1]);
subplot(6,1,3);plot(t2,OQPSK);axis([-1 8 -1 1]);
subplot(6,1,4);plot(t2,OQPSK_rc);axis([-1 8 -1 1]);
subplot(6,1,5);plot(t2,OQPSK_rc);axis([-1 8 -1 1]);
subplot(6,1,6);plot(t2,OQPSK_rc_n1);axis([-1 8 -1 1]);
% I_demo=OQPSK_rc_n1.*cos(2*pi*f1*t2);
% Q_demo=OQPSK_rc_n1.*sin(2*pi*f1*t2);
%
% y1_demo=conv(I_demo,xrc);
% y2_demo=conv(Q_demo,xrc);
%
%
%
% x1_recove=ones(1,900);
% x2_recove=ones(1,900);
%
% for i=1:100:900
% if sum(y1_demo(i:i+99))>100
% x1_recove(i:i+99)=1;
% elseif sum(y1_demo(i:i+99))<-100
% x1_recove(i:i+99)=-1;
% else x1_recove(i:i+99)=0;
% end
% end
%
% for i=1:100:900
% if sum(y2_demo(i:i+99))>100
% x2_recove(i:i+99)=1;
% elseif sum(y2_demo(i:i+99))<-100
% x2_recove(i:i+99)=-1;
% else x2_recove(i:i+99)=0;
% end
% end
%subplot(2,1,1);plot(t,x1_recove);
%subplot(2,1,2);plot(t,x2_recove);
%figure
%subplot(2,1,1);plot(y1_demo);
%subplot(2,1,2);plot(y2_demo);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -