MATLAB Code for ASK, FSK, and PSK
Comprehensive implementation of digital modulation and demodulation techniques with simulation results.
MATLAB Code for ASK Modulation and Demodulation
Fig 1: ASK Modulation and Demodulation
MATLAB Code for FSK Modulation and Demodulation
Fig 2: FSK Modulation and Demodulation
MATLAB Code for PSK Modulation and Demodulation
Fig 3: PSK Modulation and Demodulation
Understanding the MATLAB Implementation
Key Variables
Fs: Sampling frequency (must be > 2x carrier frequency).Tb: Bit duration (defines how long each symbol lasts).rng(10): Ensures your random bit generation is reproducible.
The Logic
The code uses a for loop to iterate through the bitstream. Depending on the bit value (0 or 1), it selects the appropriate carrier frequency or phase, effectively performing Hard-Decision Mapping.
Common MATLAB Errors & Fixes
1. "Undefined function or variable": Ensure you are running the script in the same folder where your variables are saved. Use clc; clear all; at the top.
2. Aliasing in Plots: If your waveforms look "jagged," increase the Fs (Sampling Frequency) to at least 10 times the carrier frequency.
3. Toolboxes: These codes run on base MATLAB, but for advanced BER analysis, you may need the Communication Toolbox.
Interactive Modulation Simulator
Launch the web-based tool to simulate digital modulation techniques.
Launch Simulator →
| Modulation | Parameter Changed | Noise Immunity | Complexity |
|---|---|---|---|
| ASK | Amplitude | Low (Highly susceptible) | Simplest |
| FSK | Frequency | High (Robust) | Moderate |
| PSK | Phase | Very High | Highest (Requires Coherent Detection) |
From Simulation to Hardware
While these MATLAB scripts simulate digital modulation in a vacuum, real-world deployment requires considering AWGN (Additive White Gaussian Noise). If you are moving to hardware like USRP (Universal Software Radio Peripheral) or RTL-SDR, you must implement Pulse Shaping (like Root-Raised Cosine) to limit bandwidth occupancy. Want to read more about raised cosine filter? Click here.
Frequently Asked Questions
Which is better: ASK, FSK, or PSK?
PSK is generally superior for high-speed data because it is the most bandwidth-efficient and noise-resistant, though it requires more complex receiver hardware.
How do I calculate BER in MATLAB?
You can use the biterr function in MATLAB to compare the transmitted bitstream with the demodulated bitstream to calculate the Bit Error Rate.
📚 Further Reading
Effect of Noise (AWGN) on ASK, FSK, and PSK
The modulated signal, x(t), is propagated through a physical communication medium—such as a wireless interface or fiber-optic cabling—where it is subject to various channel impairments. Consequently, the resulting received signal, y(t), constitutes a degraded representation of the original transmission.
This relationship is mathematically characterized by the general received signal model in the presence of fading and noise:
Where:
- x(t) denotes the transmitted modulated signal;
- h(t) represents the multiplicative fading characteristics of the channel;
- n(t) signifies the Additive White Gaussian Noise (AWGN) superimposed on the signal.
Read More: Effect of AWGN on ASK→ Effect of AWGN on FSK→ Effect of AWGN on PSK→ GET MATLAB Code
Effect of Rayleigh Fading on ASK, FSK, and PSK
This technical analysis details the lifecycle of a signal within a digital communication system, focusing on the transition from the message signal to final recovery. To facilitate long-distance transmission, information is modulated onto high-frequency carriers. However, as the signal traverses a physical medium, it encounters significant degradation modeled by the following time-domain relationship:
In this model, h(t) represents the Channel Impulse Response—specifically Rayleigh Fading—while w(t) signifies Additive White Gaussian Noise (AWGN). The text distinguishes between these two impairments: AWGN is a constant thermal noise that reduces the signal-to-noise ratio (SNR) across all frequencies, whereas Rayleigh Fading is a stochastic process caused by multipath propagation. In urban or indoor environments, signal reflections create "deep fades," resulting in rapid fluctuations of signal strength.
The performance impact is most visible in the Bit Error Rate (BER). While BER in an AWGN channel decreases exponentially with higher power, fading channels exhibit a much slower, linear decay. For instance, at 0 dB SNR using BPSK modulation, the BER effectively doubles from 0.078 (AWGN) to 0.16 (Rayleigh).
To combat these effects, systems employ Equalization to reverse channel distortion and Diversity Techniques (spatial, temporal, or frequency) to ensure redundancy.