📄 qpsk.m
字号:
function [num2,ratio2]=qpsk
fb=16;
fc=16;
fs=512;
nn=16;
%msg=randint(nn,1);
msg=[1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 1];
msg1=msg*2-1;
I1=msg1(1:2:16-1);
Q1=msg1(2:2:16);
t=0:1/fs:511/fs;
for j=1:8
I((j-1)*64+1:j*64)=I1(j);
Q((j-1)*64+1:j*64)=Q1(j);
end
y=cos(pi/4)*(I.*cos(2*pi*fc*t)-Q.*sin(2*pi*fc*t));
a=0;
y=y+a*randn(1,nn/2*64);
figure;
plot(t,y);
axis([0 1 -1.2 1.2]);
I2=y.*cos(2*pi*fc*t);
Q2=y.*sin(2*pi*fc*t)*(-1);
[b,a]=butter(2,2*fb/fs);
I3=filtfilt(b,a,I2);
Q3=filtfilt(b,a,Q2);
figure;
subplot(2,1,1);plot(t,I2);
hold on;
subplot(2,1,1);plot(t,I3,'r-');
subplot(2,1,2);plot(t,Q2);
hold on;
subplot(2,1,2);plot(t,Q3,'r-');
figure;
subplot(2,1,1);
eyescat(I3,8,512,0,32);
subplot(2,1,2);
eyescat(Q3,8,512,0,32);
m=64;
N=length(y)/m;
n=(0.5:1:N-0.5)*m;
In=(sign(I3(n))+1)/2;
Qn=(sign(Q3(n))+1)/2;
xn=[In;Qn];
xn=xn(:);
xn=xn';
[num2,ratio2]=symerr(msg,xn);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -