📄 qpsk.m
字号:
% QPSK
clear all, close all
sr=256000;
m1=2;
br=sr.*m1;
nd=1000;
ebno=3;
os=8;
%filter initialization
irfn=21;
alfs=0.5;
[xh]=hrollcoef(irfn,os,sr,alfs,1);
[xh2]=hrollcoef(irfn,os,sr,alfs,0);
%start calculation
nloop=100;
noe=0;
nod=0;
for i=1:nloop
%data generation
data1=rand(1,nd*m1)>0.5;
%qpsk modulation
[ich,qch]=qpskmod(data1,1,nd,m1);
[ich1,qch1]=compoversamp(ich,qch,length(ich),os);
[ich2,qch2]=compconv(ich1,qch1,xh);
%attenuation calculation
spow=sum(ich2.*ich2+qch2.*qch2)/nd;
attn=0.5*spow*sr/br*10.^(-ebno/10);
attn=sqrt(attn);
%add white gaussian noise
[ich3,qch3]=comb(ich2,qch2,attn);
[ich4,qch4]=compconv(ich3,qch3,xh2);
synpoint=irfn*os+1;
ich5=ich4(synpoint:os:length(ich4));
qch5=qch4(synpoint:os:length(qch4));
%qpak demoduation
[demodata]=qpskdemod(ich5,qch5,1,nd,m1);
end
%output result
subplot(4,1,1);
stairs(data1);
axis([0 100 -1 2]);
subplot(4,1,2);
plot(ich2);
axis([0 1000 -2 2]);
subplot(4,1,3);
plot(qch2);
axis([0 1000 -2 2]);
subplot(4,1,4);
stairs([demodata]);
axis([0 100 -1 2]);
figure(2)
plot(ich2,qch2);
figure(3)
plot(ich5,qch5,'*');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -