Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

BPSK QPSK 16QAM 64QAM MATLAB source code

This section of MATLAB source code covers BPSK,QPSK,16QAM and 64QAM modulation or data mapping matlab code.

This page covers modulation or mapping of binary data based on modulation type bpsk,qpsk,16qam and 64qam. It plots the constellation diagram for the same.


Setting up parameters for modulation matlab code

% Setting up parameters for modulation type
data = randint(1000,1,[1,0]); % generating binary data of 1000 bits with ones and zeros
mod_type=input('Enter the modulation type[1 for BPSK,2 for QPSK,3 for 16QAM,4 for 64QAM]: ');
norm_factor=[1.0;0.7071;0.3162;0.1543]; % normalization factors, 1.0:BPSK,0.7071:QPSK,0.3162:16QAM,0.1543:64QAM
nc=[1;2;4;6]; % number of bits per subcarrier, 1:BPSK,2:QPSK,4:16QAM,6:64QAM
input_seq = data;
k=norm_factor(mod_type);
mode=nc(mod_type);

Modulation matlab code

% Selecting constellation point as per modulation type
switch mode
case 1
b=k*[1 -1];
case 2
b=k*[1+1i -1+1i 1-1i -1-1i];
case 4
b=k*[1+1i 1+3i 1-1i 1-3i 3+1i 3+3i 3-1i 3-3i -1+1i -1+3i -1-1i -1-3i -3+1i -3+3i -3-1i -3-3i];
case 6 b=k*[3+3i 3+1i 3+5i 3+7i 3-3i 3-1i 3-5i 3-7i 1+3i 1+1i 1+5i 1+7i 1-3i 1-1i 1-5i 1-7i 5+3i 5+1i 5+5i 5+7i 5-3i 5-1i 5-5i 5-7i 7+3i 7+1i 7+5i 7+7i 7-3i 7-1i 7-5i 7-7i -3+3i -3+1i -3+5i -3+7i -3-3i -3-1i -3-5i -3-7i -1+3i -1+1i -1+5i -1+7i -1-3i -1-1i -1-5i -1-7i -5+3i -5+1i -5+5i -5+7i -5-3i -5-1i -5-5i -5-7i -7+3i -7+1i -7+5i -7+7i -7-3i -7-1i -7-5i -7-7i];
end

count=1;
count1=1;

for i=1:(ceil(length(input_seq)/mode))
temp=0;
for j=1:mode
temp=bitor(temp,bitshift(input_seq(count),(j-1)));
count=count+1;
if(count>length(input_seq))
break;
end
end
map_out(count1)=b(temp+1);
count1=count1+1;
end
figure;plot(real(map_out),imag(map_out),'r.');title('constellation');


Input in the MATLAB Window

modulation matlab code

Output in the MATLAB Window

BPSK MATLAB OUTPUT
BPSK constellation
QPSK MATLAB OUTPUT
QPSK constellation
16QAM MATLAB OUTPUT
16QAM constellation
64QAM MATLAB OUTPUT
64QAM constellation

Useful Links to MATLAB codes

Refer following as well as links mentioned on left side panel for useful MATLAB codes.
OFDM Preamble generation  Time off estimation corr  Freq off estimation corr  channel estimation  11a WLAN channel  PN sequence generation  OFDMA Tx Rx  AES DES  carrier aggregation  CCDF  FIR Filter  IIR Filter  Low Pass FIR  Viterbi decoder  CRC8 CRC32 

RF and Wireless tutorials

WLAN  802.11ac  802.11ad  wimax  Zigbee  z-wave  GSM  LTE  UMTS  Bluetooth  UWB  IoT  satellite  Antenna  RADAR 


Share this page

Translate this page