【MATLAB】16QAM変復調の関数


BPSK→16QAM

function [ output_args ] = bit_2_16QAM( TX )

TX2 = (TX(:,1:2:end) + 1j*TX(:,2:2:end))/sqrt(2);
TX2(TX2 == (-1-1j)/sqrt(2)) = -3;
TX2(TX2 == (-1+1j)/sqrt(2)) = -1;
TX2(TX2 == (1-1j)/sqrt(2)) = 3;
TX2(TX2 == (1+1j)/sqrt(2)) = 1;

output_args = (TX2(:,1:2:end) + 1j*TX2(:,2:2:end))/sqrt(10);


end

16QAM受信信号→16QAM硬判定


function [ output_args ] = QAM16_2_symbol( input_args )

Real_RX = real(input_args);
Imag_RX = imag(input_args);

Real_RX((Real_RX) > 2/sqrt(10)) = 3/sqrt(10); 
Real_RX(and(Real_RX < 2/sqrt(10) , Real_RX > 0)) = 1/sqrt(10);
Real_RX(and(Real_RX > -2/sqrt(10) , Real_RX < 0)) = -1/sqrt(10); 
Real_RX(Real_RX < -2/sqrt(10)) = -3/sqrt(10); 

Imag_RX(Imag_RX > 2/sqrt(10)) = 3j/sqrt(10); 
Imag_RX(and(Imag_RX < 2/sqrt(10) , Imag_RX > 0)) = 1j/sqrt(10);
Imag_RX(and(Imag_RX > -2/sqrt(10) , Imag_RX < 0)) = -1j/sqrt(10); 
Imag_RX(Imag_RX < -2/sqrt(10)) = -3j/sqrt(10); 

output_args = Real_RX + Imag_RX;

end

16QAM硬判定→BPSK


function [ output_args ] = symbol_2_bit_16QAM( input_args )
%SYMBOL_2_BIT この関数の概要をここに記述
%   詳細説明をここに記述
temp_size = size(input_args);
output_args = zeros(temp_size(1),length(input_args)*4);

temp = input_args*sqrt(10);
RX_Real = real(temp);
RX_Imag = imag(temp);
RX_16QAM_bit = zeros(temp_size(1),length(input_args)*2);
RX_16QAM_bit(:,1:2:end) = RX_Real;
RX_16QAM_bit(:,2:2:end) = RX_Imag;
RX_16QAM_bit(RX_16QAM_bit == 3) = (1-1j);
RX_16QAM_bit(RX_16QAM_bit == 1) = (1+1j);
RX_16QAM_bit(RX_16QAM_bit == -1) = (-1+1j);
RX_16QAM_bit(RX_16QAM_bit == -3) = (-1-1j);
Real_16QAM = real(RX_16QAM_bit);
Imag_16QAM = imag(RX_16QAM_bit);

output_args(:,1:2:end) = Real_16QAM;
output_args(:,2:2:end) = Imag_16QAM;

end