发布网友 发布时间:2022-04-23 02:06
共1个回答
热心网友 时间:2022-05-02 23:51
clear all;
close all;
clc;
biteSize = 1000;
rowBit = round(rand(1,biteSize));
%QPSK调制,每2比特对应一个符号
signalLength = biteSize/2;
IQBit = reshape(rowBit,2,signalLength);
%QPSK调制:映射符号:11 10 01 00
map = [1+1*1i; %11
1-1*1i; %10
-1+1*1i; %01
-1*-1*1i]; %00
signal = zeros(1,signalLength);
for i = 1:signalLength
if IQBit(1,i)==1 && IQBit(2,i)==1
signal(i) = map(1);
elseif IQBit(1,i)==1 && IQBit(2,i)==0
signal(i) = map(2);
elseif IQBit(1,i)==0 && IQBit(2,i)==1
signal(i) = map(3);
elseif IQBit(1,i)==0 && IQBit(2,i)==0
signal(i) = map(4);
end
end
%上变频
%经历无线信道,这里假设没有衰落
rcvSignal = signal;
%下变频
%QPSK解调
rcvIQBit = zeros(2,signalLength);
for i = 1:signalLength
min = Inf;
minIndex = 0;
for j = 1:4
diff = abs(rcvSignal(i) - map(j));
if (diff < min)
min = diff;
minIndex = j;
end
end
if minIndex == 1
rcvIQBit(1,i) = 1;
rcvIQBit(2,i) = 1;
elseif minIndex == 2
rcvIQBit(1,i) = 1;
rcvIQBit(2,i) = 0;
elseif minIndex == 3
rcvIQBit(1,i) = 0;
rcvIQBit(2,i) = 1;
elseif minIndex == 4
rcvIQBit(1,i) = 0;
rcvIQBit(2,i) = 0;
end
end
rcvRowBit = reshape(rcvIQBit,1,biteSize);
error = sum(abs(rcvRowBit - rowBit));