📄 dqpsk.m
字号:
function [num2,ratio2]=dbpsk(msg,a)
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]; a=0;
I1=msg(1:2:16-1);
I1c=I1(1);
for i=2:length(I1)
I1c=[I1c mod(sum(I1(1:i)),2)];%以0为参考
end
I1c=I1c*2-1;
Q1=msg(2:2:16);
Q1c=Q1(1);
for i=2:length(Q1)
Q1c=[Q1c mod(sum(Q1(1:i)),2)];%以0为参考
end
Q1c=Q1c*2-1;
t=0:1/fs:511/fs;
for j=1:8
I((j-1)*64+1:j*64)=I1c(j);
Q((j-1)*64+1:j*64)=Q1c(j);
end
y=cos(pi/4)*(I.*cos(2*pi*fc*t)-Q.*sin(2*pi*fc*t));
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;
Inc=In(1);
can=[0 In(1:length(In)-1)];
Inc=(can-In).^2;
Qn=(sign(Q3(n))+1)/2;
can=[0 Qn(1:length(Qn)-1)];
Qnc=(can-Qn).^2;
xn=[Inc;Qnc];
xn=xn(:);
xn=xn';
[num2,ratio2]=symerr(msg,xn);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -