Skip to main content

Calculation of SNR from FFT bins in MATLAB


SNR Estimation Overview

In digital signal processing, estimating the Signal-to-Noise Ratio (SNR) accurately is crucial. Below, we demonstrate how to calculate SNR from periodogram and FFT bins using the Kaiser Window. The beta (β) parameter is the key—it allows you to control the trade-off between main-lobe width and side-lobe levels for precise spectral analysis.

1 Define Sampling rate and Time vector
2 Compute FFT and Periodogram PSD
3 Identify Signal Bin and Frequency resolution
4 Segment Signal Power from Noise floor
5 Logarithmic calculation of SNR in dB

Method 1: Estimation from FFT Bins

This approach uses a Hamming window to estimate SNR directly from the spectral bins.

MATLAB Source Code
clc; clear; close all;
% Parameters
fs = 8000; f_tone = 1000; N = 8192; 
t = (0:N-1)/fs;

% Generate signal + noise
signal = sin(2*pi*f_tone*t);
SNR_true_dB = 20; 
signal_power = mean(signal.^2);
noise_power = signal_power / (10^(SNR_true_dB/10));
noisy_signal = signal + sqrt(noise_power) * randn(1, N);

% Apply window
w = hamming(N)';
windowed_signal = noisy_signal .* w;
U = sum(w.^2)/N; 

% FFT and PSD
X = fft(windowed_signal);
f = (0:N-1)*fs/N;
Pxx = abs(X).^2 / (fs * N * U); 

% Find signal bin
[~, signal_bin] = min(abs(f - f_tone));
signal_bins = signal_bin-1 : signal_bin+1;
signal_power_est = sum(Pxx(signal_bins));

% Noise estimation
noise_bins = setdiff(1:N/2, signal_bins); 
noise_power_est = sum(Pxx(noise_bins));

% Estimate SNR
SNR_est_dB = 10 * log10(signal_power_est / noise_power_est);
fprintf('Estimated SNR from FFT: %.2f dB\n', SNR_est_dB);

Method 2: Using Kaiser Window

Optimized spectral estimation using the Kaiser window (Beta=38) for better side-lobe suppression.

MATLAB Source Code
clc; clear; close all;
fs = 32000;
t = 0:1/fs:1-1/fs;
x = sin(2*pi*3000*t) + 0.05*randn(size(t)); % Example Signal

N = length(x);
w = kaiser(N, 38);
[Pxx, F] = periodogram(x, w, N, fs);

% SNR Estimation
freq_resolution = abs(F(2)-F(1));
[~, target_idx] = min(abs(F - 3000)); % Find 3kHz index

% Signal Power (using bins around peak)
sig_idx = target_idx-2 : target_idx+2;
Sig_power_val = sum(Pxx(sig_idx)) * freq_resolution;
Sig_power_dB = 10*log10(Sig_power_val);

% Noise Power (excluding signal)
Noise_Pxx = Pxx;
Noise_Pxx(sig_idx) = 0; 
N_avg = sum(Noise_Pxx) / (length(Pxx) - length(sig_idx));
N_power_dB = 10*log10(N_avg * fs/2);

SNR = Sig_power_dB - N_power_dB;
fprintf('SNR = %.4f dB\n', SNR);
BER vs SNR Main Page >
Fourier Transform Main Page >
Online Signal Processing Simulations Main Page >

Power Spectral Density Calculation Using FFT

Power Spectral Density (PSD) is a fundamental metric used to characterize how the power of a signal is distributed across the frequency spectrum. While a standard Fourier Transform provides the amplitude and phase of frequency components, the PSD focuses on the intensity of power, making it an essential tool for analyzing noise, stochastic processes, and signal-to-noise ratios in communication systems.

Mathematical Logic

PSD = |FFT|2 / (fs · N)

The calculation follows a strict sequence:

  • Compute the FFT of the time-domain signal.
  • Take the Absolute Magnitude.
  • Square the magnitude to find raw power.
  • Normalize by sampling rate and sample count.

Frequency Resolution (Δf)

Δf = fs / N

fs (Sampling Frequency): Higher rates increase the total range but require more samples to maintain resolution.

N (Sample Count): Increasing N provides finer frequency "bins," allowing for higher precision in identifying signal peaks.

Core Principles of Spectral Estimation

Understanding PSD requires balancing the trade-offs between frequency range and clarity:

  1. 1
    Amplitude vs. Power: Fourier Magnitude represents the "strength" of a frequency, whereas PSD represents its energy density. Squaring the magnitude is what shifts the analysis from voltage/amplitude levels to power levels.
  2. 2
    Nyquist Limits: The sampling frequency (fs) dictates the maximum detectable frequency. To avoid aliasing, the PSD can only accurately describe components up to fs / 2.
  3. 3
    Statistical Reliability: In real-world applications, raw PSD calculations (periodograms) can be "noisy." Techniques like Welch's Method or Bartlett's Method improve accuracy by averaging multiple segments of the signal to smooth out random fluctuations.

Why PSD is Crucial

PSD is the primary tool for identifying hidden periodicities in noisy data. By observing the "floor" of a PSD plot, engineers can determine the Noise Power, while the "peaks" reveal the presence of dominant signals, enabling the calculation of the Signal-to-Noise Ratio (SNR).

Read More: about Power Spectral Density Calculation Using FFT (in MATLAB)

Contact Us

Name

Email *

Message *

Popular Posts

Constellation Diagram of FSK in Detail

📘 Overview 🧮 Simulator for constellation diagram of FSK 🧮 Theory 🧮 MATLAB Code 📚 Further Reading 📚 BER vs SNR from Constellation   Binary bits '0' and '1' can be mapped to 'j' and '1' to '1', respectively, for Baseband Binary Frequency Shift Keying (BFSK) . Signals are in phase here. These bits can be mapped into baseband representation for a number of uses, including power spectral density (PSD) calculations. For passband BFSK transmission, we can modulate signal 'j' with a lower carrier frequency and signal '1' with a higher carrier frequency while transmitting over a wireless channel. Let's assume we are transmitting carrier signal fc1 for the transmission of binary bit '1' and carrier signal fc2 for the transmission of binary bit '0'. Simulator for 2-FSK Constellation Diagram Simulator for 2-FSK Constellation Diagram ...

UGC NET Electronic Science Previous Year Question Papers with Solutions

Home / Engineering & Other Exams / UGC NET 2026 PYQ ⬇️ Download Papers and Solutions 📋 Exam Pattern 💡 Preparation Tips ❓ FAQs 📊 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 2025 - Question Paper Download PDF June 2025 - Solved Paper + Explanation ...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...(MATLAB Code + Simulator)

Bit Error Rate (BER) & SNR Guide Analyze communication system performance with our interactive simulators and MATLAB tools. 📘 Theory 🧮 Simulators 💻 MATLAB Code 📚 Resources BER Definition SNR Formula BER Calculator MATLAB Comparison 📂 Explore M-ary QAM, PSK, and QPSK Topics ▼ 🧮 Constellation Simulator: M-ary QAM 🧮 Constellation Simulator: M-ary PSK 🧮 BER calculation for ASK, FSK, and PSK 🧮 Approaches to BER vs SNR What is Bit Error Rate (BER)? The BER indicates how many corrupted bits are received compared to the total number of bits sent. It is the primary figure of merit f...

FM Bandwidth and FM Band Explained

FM radio uses the frequency band from 88 MHz to 108 MHz , which is a 20 MHz-wide spectrum . This is the range of carrier frequencies available to stations. 108 MHz − 88 MHz = 20 MHz However, a single FM station occupies only about 200 kHz . This is the bandwidth of the modulated FM signal. 1. Why One FM Station Needs ~200 kHz FM uses frequency modulation . The bandwidth depends on how far the carrier swings. Carson's Rule gives the approximate FM bandwidth: B = 2 ( Δf + f m ) ...

What is Frequency Resolution?

  Formula for Frequency Resolution (in general) The frequency resolution is the smallest frequency difference between two adjacent frequency points in your sampling range. It is determined by the total frequency range and the number of frequency samples  N . The formula for the frequency resolution (or step size)  Δf  is: Δf = (f max  - f min ) / (N - 1) Where: f min  is the minimum frequency in the range (in this case, -50 Hz). f max  is the maximum frequency in the range (in this case, 50 Hz). N  is the number of frequency points / frequency bins. Using the Given Values: From the function: f min  = -50 Hz f max  = 50 Hz N  = 1000 The frequency resolution is: Δf = (50 - (-50)) / (1000 - 1) = 100 / 999 ≈ 0.1001 Hz   Understanding Frequency Resolution in Signal Processing Alternative Formula Using Time Duration Another common way to define frequency resolution, especially in time-domain signal processing, is: Δf = 1 / T W...

Ph.D. admissions in IITs without a GATE score

PhD Admission in IITs With Low CGPA approximately 6.5 – 7.0 / 10 No valid GATE score Willing to strengthen research proposal, contact faculty, apply to multiple institutes Expanded List of IITs: Eligibility & Links IIT Eligibility & Notes PhD Info Link IIT Gandhinagar Minimum: 60% marks or 6.0 CGPA (General) or 55%/5.5 (SC/ST/PD) in qualifying degree.  GATE/NET may be waived in certain cases; but short‑listing criteria likely higher. iitgn.ac.in/admissions/phd IIT Kharagpur Minimum eligibility: 60% marks or 6.5 CGPA in qualifying exam for many branches.  However brochure notes “for test & interview this minimum must be met and higher cut‑offs may apply”. iitkgp.ac.in/phd_brochure.pdf IIT Bhubaneswar Minimum: Engineering Schools – M.Tech/ME with minimum 60% marks or 6.5 CGPA....

BER performance of QPSK with BPSK, 4-QAM, 16-QAM, 64-QAM, 256-QAM, etc (MATLAB + Simulator)

📘 Overview 📚 QPSK vs BPSK and QAM: A Comparison of Modulation Schemes in Wireless Communication 📚 Real-World Example 🧮 MATLAB Code 📚 Further Reading   QPSK provides twice the data rate compared to BPSK. However, the bit error rate (BER) is approximately the same as BPSK at low SNR values when gray coding is used. On the other hand, QPSK exhibits similar spectral efficiency to 4-QAM and 16-QAM under low SNR conditions. In very noisy channels, QPSK can sometimes achieve better spectral efficiency than 4-QAM or 16-QAM. In practical wireless communication scenarios, QPSK is commonly used along with QAM techniques, especially where adaptive modulation is applied. Modulation Bits/Symbol Points in Constellation Usage Notes BPSK 1 2 Very robust, used in weak signals QPSK 2 4 Balanced speed & reliability 4-QAM ...