This repository contains a comprehensive suite of MATLAB scripts demonstrating fundamental principles of Digital Signal Processing (DSP) and Digital Communications Systems. The project is split into four distinct modules covering Fourier Analysis, Sampling and Reconstruction, Quantization, and Digital Modulation (BPSK/QPSK).
- Module 1: Fourier Analysis
- Module 2: Sampling & Reconstruction
- Module 3: Quantization & Noise Analysis
- Module 4: Digital Modulation (BPSK/QPSK)
- Prerequisites & Usage
This module implements the calculation and visualization of the Discrete Fourier Series (DFS) and the Fast Fourier Transform (FFT) for continuous signals. It explores how changing the number of sampling points
The Fourier series representation of a periodic signal
where
-
ffs.m: Computes the coefficients$a_k$ and$b_k$ for a given input function and reconstructs the signal. -
Q1_2_Changing_n.m: Analyzes how changing the number of harmonics$n$ affects the Gibbs phenomenon at signal discontinuities. -
Q1_3_Changing_T.m: Explores the effect of changing the time period$T$ on the spacing of spectral lines in the frequency domain.
This module demonstrates the Nyquist-Shannon Sampling Theorem and signal reconstruction using interpolation functions.
To reconstruct a band-limited continuous-time signal
A sampled signal
-
Q2_1_Nyquist_Rate.m: Simulates undersampling ($f_s < 2f_{max}$ ), critical sampling ($f_s = 2f_{max}$ ), and oversampling ($f_s > 2f_{max}$ ) to visualize spectral overlap. -
Q2_2_Sampling.m: Generates sampled representations of analog input waveforms. -
Q2_3_Reconstructing.m: Implements the sinc interpolation algorithm to reconstruct the continuous signal and calculates reconstruction error.
This module models the conversion of continuous amplitude samples into discrete levels (Analog-to-Digital conversion) and analyzes Signal-to-Quantization-Noise Ratio (SQNR).
For a uniform quantizer with
The quantization noise power
For a sinusoidal signal with power
-
Q3_0_Quantization.m: Core quantizer function mapping continuous inputs to discrete representation levels. -
Q3_1_Uniform_Quantization.m: Simulates linear uniform quantization and plots quantization error vs. bit depth. -
Q3_2_Selective_Quantization.m: Implements non-uniform quantization (such as$\mu$ -law or A-law companding) to protect lower-amplitude components.
This module implements baseband simulation of Binary Phase Shift Keying (BPSK) and Quadrature Phase Shift Keying (QPSK) over an Additive White Gaussian Noise (AWGN) channel.
-
BPSK: Maps 1 bit per symbol into two phases (
$0$ and$\pi$ ):$$s(t) = A \cos(2\pi f_c t + \theta_i), \quad \theta_i \in {0, \pi}$$ -
QPSK: Maps 2 bits per symbol into four phases (
$\frac{\pi}{4}, \frac{3\pi}{4}, \frac{5\pi}{4}, \frac{7\pi}{4}$ ):$$s(t) = A \cos(2\pi f_c t + \theta_i), \quad \theta_i \in \left{ \frac{\pi}{4}, \frac{3\pi}{4}, \frac{5\pi}{4}, \frac{7\pi}{4} \right}$$
-
bpsk_mod.m&bpsk_demod.m: Coherent modulator and demodulator functions for BPSK waveforms. -
qpsk_mod.m&qpsk_demod.m: Coherent modulator and demodulator functions for QPSK constellations. -
Modulation_Test.m: Main simulator generating random bitstreams, adding AWGN noise at varying$E_b/N_0$ ratios, demodulating the signals, and plotting the Bit Error Rate (BER) curves against theoretical benchmarks.
- MATLAB (R2018a or later recommended)
- Signal Processing Toolbox (optional, but recommended)
-
Launch MATLAB and navigate to the project directory.
-
Add the subfolders to the MATLAB path:
addpath('Module 1', 'Module 2', 'Module 3', 'Module 4')
-
Run a specific module script (for example, the digital modulation simulator):
run('Module 4/Modulation_Test.m')This script will output the simulated BER curve compared to the theoretical curve:
$$P_b = Q\left(\sqrt{\frac{2E_b}{N_0}}\right)$$
graph TD
A[Raw Signal Input] --> B[Time-Domain Analysis]
B --> C[Fast Fourier Transform (FFT)]
C --> D[Frequency-Domain Representation]
D --> E[Bandpass / Lowpass Digital Filtering]
E --> F[Signal Demodulation & Reconstruction]
F --> G[MATLAB Visualization Plots]