Skip to main content

MATLAB Code for Constellation Diagram of QAM configurations such as 4, 8, 16, 32, 64, 128, and 256-QAM


Overview of QAM

One of the best-performing modulation techniques is QAM [↗]. Here, we modulate the symbols by varying the carrier signal's amplitude and phase in response to the variation in the message signal (or voltage variation). So, we may say that QAM is a combination of phase and amplitude modulation.

Additionally, it performs better than ASK or PSK [↗]. In fact, any constellation for any type of modulation, signal set (or, symbols) is structured in a way that prevents them from interacting further by being distinct by phase, amplitude, or frequency.

MATLAB Script (for 4-QAM)

This is an example of 4-QAM. Here constellation size is 4 or total number of symbols/signals is 4. We map the decimal value of the input symbols (00, 01, 10, 11) to complex coordinates.

MATLAB Code 4-QAM
% This code is written by SalimWirelss.Com
clc;clear all;close all;
M = 4; % Number of levels
k = log2(M); % Bits per symbol
rng(10) % seed
N = 10000; % Number of bits
InputBits = randi([0 1],1,N); 
InputSymbol_matrix = reshape(InputBits,length(InputBits)/k,k); 
InputSymbols_decimal = bi2de(InputSymbol_matrix); 

for n= 1:N/k
    if InputSymbols_decimal(n)==0
        QAM(n)= complex(1,1);
    elseif InputSymbols_decimal(n)==1
        QAM(n)= complex(-1,1);
    elseif InputSymbols_decimal(n)==2
        QAM(n)= complex(1,-1);
    else
        QAM(n)= complex(-1,-1);
    end
end

% Transmission over AWGN
snrdB = 10;
Y=awgn(QAM,snrdB); 

% Threshold Detection
for n= 1:N/k
    if (real(Y(n))>0 && imag(Y(n))>0)
        Z(n)=complex(1,1);
    elseif (real(Y(n))>0 && imag(Y(n))<0 complex="" elseif="" imag="" n="" real="" z="">0)
        Z(n)=complex(-1,1);
    else
        Z(n)=complex(-1,-1);
    end
end

figure(1); scatter(real(QAM), imag(QAM)); xlim([-3, 3]); ylim([-3, 3]); title('Transmitted');
figure(2); scatter(real(Y), imag(Y)); xlim([-3, 3]); ylim([-3, 3]); title('Received');
4-QAM Transmitted
Fig 1: Constellation points of 4-QAM (Transmitted)
4-QAM Received
Fig 2: Constellation points of 4-QAM (Received)

Another MATLAB Code (for 16-QAM)

A custom implementation for 16-QAM modulation and demodulation including normalization to unit average power.

MATLAB Code 16-QAM
% The code is developed by SalimWireless.Com
clc; clear; close all;
M = 16; 
numSymbols = 10000; 
data = randi([0 M-1], numSymbols, 1); 
modData = qammod_custom(data, M);
snrdB = 15;
Y = awgn(modData,snrdB); 

figure;
subplot(2,1,1); scatter(real(modData), imag(modData), 'o'); grid on;
title('Constellation Diagram (16-QAM)');
subplot(2,1,2); scatter(real(Y), imag(Y), 'o'); grid on;
title('Received Noisy Signal');

% Custom Functions
function modData = qammod_custom(data, M)
    constellation = [-3-3i, -3-1i, -1-3i, -1-1i, -3+3i, -3+1i, -1+3i, -1+1i, ...
                      +3-3i, +3-1i, +1-3i, +1-1i, +3+3i, +3+1i, +1+3i, +1+1i];
    constellation = constellation / sqrt(mean(abs(constellation).^2)); 
    modData = constellation(data + 1);
end
16-QAM Output

MATLAB for M-ary QAM (General)

This code supports multiple configurations such as 4, 8, 16, 32, 64, 128, and 256-QAM using MATLAB's built-in functions.

MATLAB Code M-ary QAM
% The code is developed by SalimWireless.com
M = 32;  % Order of QAM
N = 1000;  % Symbols
SNR = 10; 
dataSymbols = randi([0 M-1], N, 1);
txSignal = qammod(dataSymbols, M);
rxSignal = awgn(txSignal, SNR, 'measured');
demodulatedSymbols = qamdemod(rxSignal, M);
SER = sum(dataSymbols ~= demodulatedSymbols) / N;
disp(['Symbol Error Rate: ', num2str(SER)]);

figure;
subplot(2, 1, 1); plot(real(txSignal), imag(txSignal), 'o'); title('Transmitted');
subplot(2, 1, 2); plot(real(rxSignal), imag(rxSignal), 'o'); title('Received');
M-ary QAM Constellation

BER vs SNR Analysis

Evaluate the performance of various QAM configurations by plotting Bit Error Rate against Signal-to-Noise Ratio.

Interactive QAM Simulator

Visualize 4-QAM, 16-QAM, 64-QAM, and 256-QAM constellations instantly with our online tool.

Simulator Preview
Launch Simulator Now Other Simulations



Contact Us

Name

Email *

Message *

Popular Posts

UGC NET Electronic Science Previous Year Question Papers with Solutions

Download Papers and Solutions Exam Pattern Preparation Tips FAQs More Home / Engineering & Other Exams / UGC NET 2026 PYQ 📊 Exam Highlights: Electronic Science (88) Feature Details Junior Research Fellowship (JRF) ₹37,000 + HRA per month Eligibility M.Sc/M.Tech in Electronics (55%) Validity of Certificate JRF (3 Years) | Lectureship (Lifetime) 📥 Download UGC NET Electronics PDFs Complete collection of previous year question papers, answer keys and explanations for Subject Code 88. Start Downloading 📂 View All Question Papers June 2026 - Question Paper Download PDF June 202...

GMSK BER vs SNR (with Simulation)

  GMSK Performance: Why the BER vs. SNR Curve Matters If you’ve ever wondered why GMSK (Gaussian Minimum Shift Keying) became the backbone of the global GSM revolution, the answer lies in its unique balance of spectral efficiency and power performance. But there is no free lunch in engineering. To get that sleek, narrow spectrum, you have to pay a price in Bit Error Rate (BER) . In this guide, we break down the theoretical BER vs. SNR performance of GMSK, the "magic" of the BT product, and how to optimize your link budget for real-world conditions. What is GMSK and Why Should You Care? GMSK is a derivative of MSK (Minimum Shift Keying) that uses a Gaussian pre-modulation filter. This filter "smooths" the phase transitions, significantly reducing sideband power. The result? A constant envelope signal that allows you to use high-efficiency Class-C amplifiers without distorting the signal. This is the secr...

The output voltage V0 (in Volt) for the network given in the Figure is ___

  Find the Output Voltage V o Solve the given circuit using Kirchhoff's Current Law (KCL), Ohm's law, and the supernode method. 1. Given Circuit Parameters Current source 1 mA Resistors 1 kΩ Each resistor Voltage source 6 V Required V o 2. Understand the Circuit The circuit contains a 1 mA current source, four 1 kΩ resistors, and a 6 V source connected between the two midpoint nodes. The output voltage is measured between the top and bottom rails. Reference node Take the bottom rail as ground: 0 V . Let the top rail voltage be V T , and...

What is a Supernode?

  Circuit Analysis What Is a Supernode? A supernode is formed when an ideal voltage source connects two non-reference nodes. It allows us to apply Kirchhoff's Current Law (KCL) to the combined circuit boundary. 1. Understanding a Supernode In nodal analysis, a voltage source between two unknown-voltage nodes makes the current through that source difficult to express directly using Ohm's law. We combine the two nodes and the voltage source into one extended region called a supernode. Key idea Apply KCL around the outer boundary of the supernode, then use the voltage source to write an additional voltage equation. 2. Supernode Circuit Diagram The voltage source connects nodes V L an...

A binary ripple counter is designed to count (0)₁₀ to (64)₁₀. Which of the following is/are the number of flip-flops required ...

  Q. A binary ripple counter is designed to count  (0)₁₀ to (64)₁₀ . Which of the following is/are the number of flip-flops required to design the counter?   (A) 6 (B) 7 (C) 4 (D) 5 Solution A binary ripple counter must count from (0)₁₀ to (64)₁₀ , including both endpoints. Step 1: Calculate the total number of states Since both 0 and 64 are included, add 1 to the difference: N = Last value − First value + 1 N = 64 − 0 + 1 = 65 states The counter visits every integer from 0 through 64: 0, 1, 2, 3, ..., 63, 64 There are 65 distinct states in total. Step 2: Calculate the number of flip-flops Each flip-flop stores one bit. With n flip-flops, the counter can represent 2ⁿ distinct states. 2⁶ = 64 states (not enough) 2⁷ = 128 states (eno...

Parametric Down-Conversion of Photons

  Nonlinear Optics One incoming photon is converted into two lower-energy photons, typically in a nonlinear optical medium. Energy is conserved: E in = E 1 + E 2 E in ​ = E 1 ​ + E 2 ​ . Parametric Down-Conversion A nonlinear optical process in which one pump photon is converted into two lower-energy photons, known as the signal and idler photons. 1 Energy Conservation The energy of the pump photon equals the sum of the energies of the signal and idler photons. \[ \boxed{\hbar\omega_p=\hbar\omega_s+\hbar\omega_i} \] \[ \boxed{\omega_p=\omega_s+\omega_i} \] ωₚ Pump angular frequency ...

SRAM, DRAM, EPROM, MRAM, and DDRAM Explained

Computer Fundamentals Types of Memory and Their Technologies Understand the fundamental relationship between different types of computer memory and the technologies used to implement them. Fundamental Matching Memory type, technology, and key characteristics Memory Type Technology Key Characteristic Cache Memory SRAM Very fast; stores frequently accessed data Main Memory DRAM Holds programs and data currently in use Au...

The cutoff frequency (in GHz) for the dominant TE10 mode of an air-filled rectangular waveguide of ...

  Q. The cutoff frequency (in GHz) for the dominant TE10 mode of an air-filled rectangular waveguide of inner dimension 0.28 inch×0.14 inch is __. (rounded off to two decimal places). Given Information Waveguide dimensions = 0.28 inch × 0.14 inch Wider dimension (a) = 0.28 inch Smaller dimension (b) = 0.14 inch Medium = Air Dominant mode = TE 10 Speed of light (c) = 3 × 10 8 m/s Step 1: Cutoff Frequency Formula The cutoff frequency of a rectangular waveguide is: f c = (c / 2) √[(m/a) 2 + (n/b) 2 ] For the dominant TE 10 mode: m = 1, n = 0 f c = c / 2a Step 2: Convert Inch into Meter We know that 1 inch = 0.0254 meter. a = 0.28 × 0.0254 a = 0.007112 m ...