Lesson 29-Communication System Simulation and Modulation-Demodulation Techniques

Introduction: The Invisible Fabric of Modern Life

Every time you make a phone call, stream a video, or check your email, you’re relying on sophisticated communication systems that would have seemed like magic to engineers just a century ago. These systems—wireless networks, satellite links, fiber-optic cables—all rely on the same fundamental principles: modulating information onto carrier waves, transmitting those waves through a channel, and demodulating them at the receiver.

MATLAB is one of the most powerful tools for designing, simulating, and analyzing communication systems. The Communications Toolbox (and related toolboxes like 5G Toolbox, WLAN Toolbox) provide a comprehensive set of functions for:

  • Generating communication signals
  • Modulating and demodulating data
  • Simulating channels (AWGN, fading, etc.)
  • Analyzing system performance (BER, EVM, ACLR)

In this article, we’re going to dive deep into communication system simulation. We’ll start with the fundamentals (what is modulation, and why do we need it?), then explore specific modulation schemes (BPSK, QPSK, QAM), simulate their performance over noisy channels, and visualize the results.

By the end of this article, you’ll be able to design and simulate a complete communication link in MATLAB—from bit generation to demodulation and BER analysis.

Why Modulation? (The Fundamental Problem of Wireless Communication)

Before we dive into MATLAB code, let’s understand why we modulate signals in the first place.

The Problem: Baseband Signals Can’t Travel Far

If you want to send digital data (bits: 0s and 1s) over a wireless link, you might think: “I’ll just transmit a voltage pulse for 1 and no pulse for 0.”

This is called baseband transmission, and it has a fundamental problem: baseband signals don’t propagate well through space.

Here’s why:

  1. Antenna size: To efficiently radiate a signal, your antenna needs to be on the order of the wavelength. For a 1 MHz baseband signal, the wavelength is 300 meters. That’s a BIG antenna.
  2. Path loss: Lower frequency signals experience less path loss, but they also require larger antennas.
  3. Multipath fading: Baseband signals are more susceptible to destructive interference.
  4. Spectrum allocation: Governments allocate specific frequency bands for different services. You can’t just transmit at any frequency.

The Solution: Modulation

Modulation is the process of imprinting your baseband signal onto a carrier wave—a high-frequency sine wave. By shifting your signal to a higher frequency (the “carrier frequency”), you solve all the problems above:

  • Antennas become practical (for 2.4 GHz Wi-Fi, wavelength is 12.5 cm)
  • Path loss is reduced
  • You can operate in allocated spectrum bands

Types of Modulation

There are three basic ways to modulate a carrier wave:

Carrier wave: s(t) = A(t) * cos(2πf_c t + φ(t))

1. Amplitude Modulation (AM):  Vary A(t) (amplitude)
2. Frequency Modulation (FM):  Vary f_c (frequency)
3. Phase Modulation (PM):     Vary φ(t) (phase)

In digital communication, we use digital modulation schemes that map bits to specific amplitude/phase/frequency configurations:

  • PSK (Phase Shift Keying): Bits map to phases
  • QAM (Quadrature Amplitude Modulation): Bits map to both amplitude and phase
  • FSK (Frequency Shift Keying): Bits map to frequencies

Communications Toolbox Overview

MATLAB’s Communications Toolbox provides a comprehensive set of functions and System objects for simulating communication systems.

Key Components

ComponentDescriptionExamples
Source codingCompress data before transmissionarithmeticEncoder
Channel codingAdd redundancy for error correctionconvenc (convolutional coding), ldpcEncode
ModulationMap bits to symbolspskmod, qammod, comm.QPSKModulator
Channel modelsSimulate real-world channelsawgn, comm.AWGNChannel, comm.RicianChannel
DemodulationRecover bits from received symbolspskdemod, qamdemod
EqualizationCompensate for channel distortioncomm.DecisionFeedbackEqualizer
SynchronizationCarrier and symbol timing recoverycomm.CarrierSynchronizer
AnalysisMeasure system performancebiterr, eyediagram

Using System Objects vs. Functions

The Communications Toolbox provides two programming models:

  1. Function-based: y = pskmod(x, M) — simple, immediate.
  2. System object-based: h = comm.QPSKModulator(); y = step(h, x) — more flexible, supports streaming.

When to use which:

  • Use functions for simple, one-off simulations.
  • Use System objects for large-scale simulations, real-time processing, or when you need to maintain state between calls.

Signal Generation: Creating Communication Signals in MATLAB

Before we modulate data, we need to understand how to generate signals in MATLAB.

Basic Signal Generation with cos() and sin()

%% Generate a basic sinusoid
fs = 1000;          % Sampling frequency (Hz)
f0 = 50;            % Signal frequency (Hz)
t = 0:1/fs:0.1;   % Time vector (0.1 seconds)

% Generate sinusoid
signal = cos(2*pi*f0*t);

% Plot
figure('Name', 'Basic Signal Generation', 'Color', 'w');
plot(t, signal, 'b-', 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Amplitude');
title('50 Hz Cosine Wave (fs = 1000 Hz)');
grid on;

Using comm.SineWave (System Object)

For more sophisticated signal generation (with configurable phase, samples per frame, etc.):

%% Generate a sine wave using comm.SineWave
hSine = comm.SineWave();
hSine.Frequency = 100;      % 100 Hz
hSine.PhaseOffset = 0;      % 0 radians
hSine.SamplesPerFrame = 1000; % 1000 samples per frame
hSine.SampleRate = 10000;   % 10 kHz sample rate

% Generate one frame of data
signal = hSine();  % No input argument = generate next frame

% Time vector for plotting
t = (0:length(signal)-1) / hSine.SampleRate;

% Plot
figure('Name', 'comm.SineWave Example', 'Color', 'w');
plot(t, signal, 'r-', 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Amplitude');
title('100 Hz Sine Wave (generated by comm.SineWave)');
grid on;

Generating Random Bits (The Source of Our Data)

In communication systems, we typically start with a random sequence of bits:

%% Generate random bits
rng(42);  % For reproducibility

% Generate 1000 random bits (0s and 1s)
numBits = 1000;
bits = randi([0, 1], numBits, 1);

% Plot first 50 bits as a stem plot
figure('Name', 'Random Bit Sequence', 'Color', 'w');
stem(0:49, bits(1:50), 'b', 'LineWidth', 2, 'Marker', 'none');
xlabel('Bit Index');
ylabel('Bit Value');
title('First 50 Random Bits');
ylim([-0.2, 1.2]);
grid on;

Membership Required

You must be a member to access this content.

View Membership Levels

Already a member? Log in here
Share your love