image thumbnail

very simple and short 16quam modulation and demodulation

by

 

after seeing some long and complex 16quam modulations and demodulations I've decided to try by mysef

qam16_mod_demod.m
clear all
close all
clc 

symbnum=50;
M=16;
subch=4;
R_m=log2(M);
P_tr=1;
x=sqrt(P_tr/2.5);

data_bin=rand(1,R_m*symbnum*subch)>0.5;

% data_bin=[0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1
%     0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1
%     1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1
%     1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1]';
% data_bin=data_bin(:)';


%%%%% 16QAM modulation %%%%%

data_R_m=reshape(data_bin,R_m,[]);
data_16QAM=(1-2*data_R_m(2,:)).*(data_R_m(4,:)+0.5)*x+...
    1i*(1-2*data_R_m(1,:)).*(data_R_m(3,:)+0.5)*x;



%%%%% 16QAM demodulation %%%%

demod_16QAM=zeros(size(data_R_m));
demod_16QAM(2,:)=0.5-0.5*sign(real(data_16QAM));
demod_16QAM(4,:)=(abs(real(data_16QAM))/x==1.5);
demod_16QAM(1,:)=0.5-0.5*sign(imag(data_16QAM));
demod_16QAM(3,:)=(abs(imag(data_16QAM))/x==1.5);
demod_16QAM=demod_16QAM(:)';

% demod_16QAM=reshape(demod_16QAM,R_m,[]);

Contact us