本人MATLAB学习小白,仅做笔记记录和分享~~
% qpsk && oqpsk
clc;
close all;
Ts=1;
fc=10;
N_sample=16;
N_sum=100;
dt=1/fc/N_sample;
t=0:dt:N_sum*Ts-dt;
T=dt*length(t);
d1=sign(randn(1,N_sum));
d2=sign(randn(1,N_sum));
gt=ones(1,fc*N_sample); %基本码元波形
s1=sigxpand(d1,fc*N_sample);
s2=sigxpand(d2,fc*N_sample);
b1=conv(gt,s1);
b2=conv(gt,s2);
s1=b1(1:length(s1));
s2=b2(1:length(s2));
st_qpsk=s1.*cos(2*pi*fc*t)-s2.*sin(2*pi*fc*t); %QPSK波形
s2_delay=[ones(1,fc*N_sample/2),s2(1:end-fc*N_sample/2)]; %% 重要!!!
st_oqpsk=s1.*cos(2*pi*fc*t)-s2_delay.*sin(2*pi*fc*t);
%QPSK 与OQPSK原始信号波形
subplot(421),plot(t,st_qpsk);xlabel('QPSK原始信号');
axis([0,40,-2,2])
subplot(422),plot(t,st_oqpsk);xlabel('OQPSK原始信号');
axis([0,40,-2,2])
%-----------将QPSK和OQPSK经过BPF--------------%
bpf1=sinc(2/Ts*t).*cos(2*pi*fc*t);
st_bpf_qpsk=conv(st_qpsk,bpf1);
st_bpf_qpsk=st_bpf_qpsk(1:length(st_qpsk));
st_bpf_oqpsk=conv(st_oqpsk,bpf1);
st_bpf_oqpsk=st_bpf_oqpsk(1:length(st_oqpsk));
%QPSK 与OQPSK原始信号波形
subplot(423),plot(t,st_bpf_qpsk);xlabel('QPSK经过低通滤波器后信号');
axis([0,40,-40,40]);
subplot(424),plot(t,st_bpf_oqpsk);xlabel('OQPSK经过低通滤波器后信号');
axis([0,40,-40,40]);
%----------------------end--------------------%
%-----------QPSK和OQPSK经过BPF前频谱------------------%
[f,sf_qpsk]=T2F(t,st_qpsk(1:length(t)));
[f,sf_oqpsk]=T2F(t,st_oqpsk(1:length(t)));
subplot(425),plot(f,abs(sf_qpsk));xlabel('QPSK经过滤波器前的频谱');hold on;
subplot(426),plot(f,abs(sf_oqpsk),'r--');xlabel('OQPSK经过滤波器前的频谱');
%----------------------end--------------------%
%-------------QPSK和OQPSK经过BPF后频谱-----------------%
[f,sf_qpsk_lpf]=T2F(t,st_bpf_qpsk(1:length(t)));
[f,sf_oqpsk_lpf]=T2F(t,st_bpf_oqpsk(1:length(t)));
subplot(427),plot(f,abs(sf_qpsk_lpf));hold on;xlabel('QPSK经过滤波器后的频谱');
subplot(428),plot(f,abs(sf_oqpsk_lpf),'r--');xlabel('OQPSK经过滤波器后的频谱');
%----------------------end--------------------%