FSK Modulation in MATLAB: Code, Explanation, and Results
Advertisement
This document provides an overview of Frequency Shift Keying (FSK) modulation, along with corresponding MATLAB code. We’ll explore the underlying principles, the MATLAB implementation, and the expected input/output behavior.
Introduction to FSK Modulation
FSK, or Frequency Shift Keying, is a digital modulation technique where the frequency of a carrier signal is varied according to the digital data being transmitted (1 or 0). Essentially:
- Binary Logic 1: Represented by a higher carrier frequency (f1).
- Binary Logic 0: Represented by a lower carrier frequency (f2).

Figure 1: FSK Modulation
As depicted above, the inputs are digital binary data and an analog carrier signal, and the output is the analog FSK modulated signal.
FSK modulation offers improved noise immunity, but this comes at the expense of requiring a larger bandwidth compared to other modulation techniques.
MATLAB Code for FSK Modulation
clear;
clc;
b = input('Enter the Bit stream \n ');
%b = [0 1 0 1 1 1 0];
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);
end
end
bw = bw(100:end);
wo = 2*(2*pi*t);
W = 1*(2*pi*t);
sinHt = sin(wo+W);
sinLt = sin(wo-W);
st = sin(wo+(bw).*W);
subplot(4,1,1)
plot(t,bw)
grid on ;
axis([0 n -2 +2])
subplot(4,1,2)
plot(t,sinHt)
grid on ;
axis([0 n -2 +2])
subplot(4,1,3)
plot(t,sinLt)
grid on ;
axis([0 n -2 +2])
subplot(4,1,4)
plot(t,st)
grid on ;
axis([0 n -2 +2])
Fs=1;
figure
%pburg(st,10)
periodogram(st)
Code Explanation
- Initialization: The script starts by clearing the workspace and command window.
- Input: The user is prompted to enter the bit stream. Example:
[0 1 0 1 1 1 0]. - Bit Representation: The code maps binary 0 to -1 and binary 1 to 1. This is represented by
b_p. - Waveform Generation: Sine waves are generated for the higher frequency (
sinHt) and lower frequency (sinLt) carriers. Thestvariable holds the final FSK modulated signal. - Plotting: The code plots the following in subplots:
- Binary data representation.
- High-frequency carrier.
- Low-frequency carrier.
- FSK modulated signal.
- Periodogram: A periodogram is generated to display the frequency spectrum of the FSK signal.
Input and Output
After unzipping and running the FSKModulation.m file in MATLAB, you will be prompted to enter the bit stream.

Figure 2: Input Prompt
Enter your desired bit stream (e.g., [0 1 0 1 1 1 0]) and press “ENTER.” The script will then generate the output plots and the periodogram.

Figure 3: Output Plots
The output displays the binary input, the high and low-frequency carriers, and the resulting FSK modulated signal. The periodogram shows the frequency components of the FSK signal.
Download
You can download the MATLAB code as a .rar file here: Download FSKModulation rar file
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
