function Symbol=QAM16Mod(bit)
% 16QAM modulation
% s3 s2 s1 s0 ml mQ
% 0 0 0 0 3A 3A
% 0 0 0 1 A 3A
% 0 0 1 1 -A 3A
% 0 0 1 0 -3A 3A
% 0 1 0 0 3A A
% 0 1 0 1 A A
% 0 1 1 1 -A A
% 0 1 1 0 -3A A
% 1 1 0 0 3A -A
% 1 1 0 1 A -A
% 1 1 1 1 -A -A
% 1 1 1 0 -3A -A
% 1 0 0 0 3A -3A
% 1 0 0 1 A -3A
% 1 0 1 1 -A -3A
% 1 0 1 0 -3A -3A
% note:A=1/sqrt(10)
%
bitlength=length(bit);
A=1/sqrt(10);
%bit(ii*4)=s3,bit(ii*4-1)=s2,bit(ii*4-2)=s1,bit(ii*4-3)=s0
for ii=1:bitlength/4
if bit(ii*4)==0
if bit(ii*4-1)==0 %00**
if bit(ii*4-2)==0
if bit(ii*4-3)==0
QAM16(ii)=3*A+3*A*j;
else
QAM16(ii)=A+3*A*j;
end
else
if bit(ii*4-3)==0
QAM16(ii)=-3*A+3*A*j;
else
QAM16(ii)=-A+3*A*j;
end
end
else %01**
if bit(ii*4-2)==0
if bit(ii*4-3)==0
QAM16(ii)=3*A+A*j;
else
QAM16(ii)=-A+A*j;
end
else
if bit(ii*4-3)==0
QAM16(ii)=-3*A+A*j;
else
QAM16(ii)=-A+A*j;
end
end
end
else
if bit(ii*4-1)==0 %10**
if bit(ii*4-2)==0
if bit(ii*4-3)==0
QAM16(ii)=-3*A-3*A*j;
else
QAM16(ii)=-A-3*A*j;
end
else
if bit(ii*4-3)==0
QAM16(ii)=-3*A-3*A*j;
else
QAM16(ii)=-A-3*A*j;
end
end
else %11**
if bit(ii*4-2)==0
if bit(ii*4-3)==0
QAM16(ii)=-3*A-A*j;
else
QAM16(ii)=-A-A*j;
end
else
if bit(ii*4-3)==0
QAM16(ii)=-3*A-A*j;
else
QAM16(ii)=-A-A*j;
end
end
end
end
end