BPSK, QPSK, 16QAM, 64QAM Modulation MATLAB Code
Advertisement
This section provides MATLAB source code examples for BPSK, QPSK, 16QAM, and 64QAM modulation (or data mapping). This page details the modulation/mapping of binary data based on the modulation type: BPSK, QPSK, 16QAM, and 64QAM. It also plots the constellation diagram for each modulation scheme.
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);
This code segment initializes the necessary parameters for the modulation process. It generates random binary data, prompts the user to select the modulation type, and sets the appropriate normalization factor and number of bits per subcarrier based on the chosen modulation.
## Modulation (MATLAB Code)
```matlab
% 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');
This section performs the core modulation. It selects the constellation point based on the mode variable (determined by the user’s choice of modulation type). The switch statement assigns the appropriate complex values (b) representing the constellation points for BPSK, QPSK, 16QAM, or 64QAM. The code then iterates through the input binary sequence, mapping groups of bits to these complex constellation points and plotting the resulting constellation diagram.
Input in the MATLAB Window

Input required from the user in MATLAB.
Output in the MATLAB Window

MATLAB output after running the code.
BPSK Constellation

The resulting BPSK constellation diagram.
QPSK Constellation

The resulting QPSK constellation diagram.
16QAM Constellation

The resulting 16QAM constellation diagram.
64QAM Constellation

The resulting 64QAM constellation diagram.
Explore MATLAB Wireless Communications & Modulation
- AM/FM/PM Modulation in MATLAB
- ASK Modulation in MATLAB
- FSK Modulation in MATLAB
- MSK Modulation in MATLAB
- GMSK Modulation in MATLAB
- PSK Modulation (MATLAB Code)
- BPSK, QPSK, 16-QAM, 64-QAM (MATLAB Code)
- On-Off Keying (OOK) (MATLAB Code)
- OFDM (MATLAB Code)
- OFDMA Basics (MATLAB Code)
- SC-FDMA Basics (MATLAB Implementation)
- WiMAX OFDM Basics (MATLAB Code)
- WLAN OFDM Basics (MATLAB Code)
- LTE Basics (MATLAB Code)
- OFCDM (MATLAB Code)
- Beamforming (MATLAB Code QAM)
- 2x2 MIMO & STBC (MATLAB Code)
- CDMA (MATLAB Code)
- Zigbee Transceiver (MATLAB Code)
Continue Learning Modulation Types
- AM Vs. FM Vs. PM : Difference between Analog Modulation Techniques
- ASK Vs. FSK Vs. PSK : Difference between Digital Modulation Techniques
- PAM Vs. PWM Vs. PPM : Difference between Pulse Modulation Techniques
- BPSK Vs. QPSK : Key Differences
- 16-QAM Vs. 64-QAM Vs. 256-QAM : Key Differences
- 512-QAM Vs. 1024-QAM Vs. 2048-QAM Vs. 4096-QAM
- 4096QAM Modulation Used in Wi-Fi 7
- MSK Vs. GMSK : Modulation Technique used in GSM
- LORa Modulation Used in LoRaWAN
- 10% ASK & 100% ASK Modulation used in NFC
- OOK Vs. VPPM Vs. CSK : Visible Light Communication (VLC) Modulation Techniques
- QPSK Vs. OQPSK Vs. PI/4 QPSK
- PAM4 Modulation Used in Gigabit Ethernet
- CCK Vs. DSSS Vs. OFDM Used in WLAN (Wi-Fi) Standards
