目录
QPSK调制流程图:
QPSK解调流程图:?
?
1、Figure1:为发送端比特流情况图:?
?
?
? ? ? ?从Figure1看出发送端发送的比特流信息…[ak,bk]…情况:奇数进入I路,偶数进入Q路。比特进入I路与Q路情况如下表总结所示:?
K | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
数据比特 | 1 | 1 | -1 |-1 | -1 |-1 | -1| 1 | 1|1 | -1|-1 | 1|-1 | -1|-1 | 1|-1 | 1|-1 |
I路 | 1 | -1 | -1 | -1 | 1 | -1 | 1 | -1 | 1 | 1 |
Q路 | 1 | -1 | -1 | 1 | 1 | -1 | -1 | -1 | -1 | -1 |
?2、Figure2:与载波相乘之后的I路与Q路的波形图以及QPSK的波形图:
?
3、Figure3:QPSK经过解调之后得到的输出二进制信息比特以及解调得到的I路与Q路上面的比特波形图:?
?
?
? ?从Figure3看出接收端接收且解调的比特流信息…[ak,bk]…进入I路与Q路的情况:奇数进入I路,偶数进入Q路。比特进入I路与Q路情况以及解调得出的总比特数据如下表总结所示:?
K | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
数据比特 | 1 | 1 | -1 |-1 | -1 |-1 | -1| 1 | 1|1 | -1|-1 | 1|-1 | -1|-1 | 1|-1 | 1|-1 |
I路 | 1 | -1 | -1 | -1 | 1 | -1 | 1 | -1 | 1 | 1 |
Q路 | 1 | -1 | -1 | 1 | 1 | -1 | -1 | -1 | -1 | -1 |
? ? ?将Figure3与Figure1的I路与Q路的比特信息及波形图进行对比,发现接收端与发送端的I路与Q路的比特信息以及波形一致;
? ? ?将发送端的输入比特流信息…[ak,bk]…以及波形与QPSK解调得出的比特信息流以及波形进行对比,发现比特信息流与对应的波形均一致。说明本次QPSK的调制与解调仿真实验成功!
clear all;clc;
N=20; % The number of bits
T=1;% The bit period
fc=2; % The carrier frequency
Fs=100;% the sample frequency
bitstream=randi([0,1],1,N);% randomly generate the bitstream
bitstream=2*bitstream-1;% 0 to -1; 1 to 1
l=[];Q=[];
for i=1:N
if mod(i,2)~=0
l=[l,bitstream(i)];
else
Q=[Q,bitstream(i)];
end
end
% using plot to compare bitsteam, I, Q
bit_data=[];
for i=1:N
bit_data=[bit_data,bitstream(i)*ones(1,T*Fs)];
end
l_data=[];Q_data=[];
for i=1:N/2
l_data=[l_data,l(i)*ones(1,T*Fs*2)];
Q_data=[Q_data,Q(i)*ones(1,T*Fs*2)];
end
% plot
figure();
t=0:1/Fs:N*T-1/Fs;
subplot(3,1,1)
plot(t,bit_data);legend('Bitstream')
subplot(3,1,2)
plot(t,l_data);legend('l Bitstream')
subplot(3,1,3)
plot(t,Q_data);legend('Q Bitstream')
% carrier signal
bit_t=0:1/Fs:2*T-1/Fs;
l_carrier=[];Q_carrier=[];
for i=1:N/2
l_carrier=[l_carrier,l(i)*cos(2*pi*fc*bit_t)];
Q_carrier=[Q_carrier,Q(i)*cos(2*pi*fc*bit_t+pi/2)];
end
% transmit signal
QPSK_signal=l_carrier+Q_carrier;
% plot
figure();
subplot(3,1,1)
plot(t,l_carrier);legend('l signal')
subplot(3,1,2)
plot(t,Q_carrier);legend('Q signal')
subplot(3,1,3)
plot(t,QPSK_signal);legend('QPSK signal')
snr=1;% signal to noise rate
% Receive singal
QPSK_receive=awgn(QPSK_signal,snr);
% demodulate
for i=1:N/2
l_output=QPSK_receive(1,(i-1)*length(bit_t)+1:i*length(bit_t)).*cos(2*pi*fc*bit_t);
if sum(l_output)>0
l_recover(i)=1;
else
l_recover(i)=-1;
end
Q_output=QPSK_receive(1,(i-1)*length(bit_t)+1:i*length(bit_t)).*cos(2*pi*fc*bit_t+pi/2);
if sum(Q_output)>0
Q_recover(i)=1;
else
Q_recover(i)=-1;
end
end
bit_recover=[];
for i=1:N
if mod(i,2)~=0
bit_recover=[bit_recover,l_recover((i-1)/2+1)];
else
bit_recover=[bit_recover,Q_recover(i/2)];
end
end
% using plot to compare bitsteam, I, Q
recover_data=[];
for i=1:N
recover_data=[recover_data,bit_recover(i)*ones(1,T*Fs)];
end
l_recover_data=[];Q_recover_data=[];
for i=1:N/2
l_recover_data=[l_recover_data,l_recover(i)*ones(1,T*Fs*2)];
Q_recover_data=[Q_recover_data,Q_recover(i)*ones(1,T*Fs*2)];
end
% plot
figure();
t=0:1/Fs:N*T-1/Fs;
subplot(3,1,2)
plot(t,l_recover_data);legend('l Bitstream')
subplot(3,1,3)
plot(t,Q_recover_data);legend('Q Bitstream')
subplot(3,1,1)
plot(t,recover_data);legend('Bitstream')
?