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 >

Contact Us

Name

Email *

Message *

Popular Posts

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 ...

UGC NET Electronic Science June 2025 Question Paper with Answer Key & Detailed Solutions

Home / UGC NET PYQ / June 2025 Solved UGC NET Electronic Science June 2025 Question Paper with Answer Key and Full Explanations 📥 Download Question Paper (PDF) 2025 2024 2023 2022 2021 2020 Explanations 1.  Answer: Option (3) For forming a p-type semiconductor, the dopant must be a trivalent impurity (three valence electrons) so that it creates acceptor levels and holes become the majority carriers. Among the given elements, boron (B) is a group-III element (trivalent). Arsenic (As) and phosphorus (P) are group-V (pentavalent) donors that produce n-type material, and germanium (Ge) is a group-IV element usually used as the semiconductor, not as an acceptor dopant. Hence, doping an intrinsic semiconductor with B produces a p-type semiconductor. 2.  Answer: Option (4) The ohmic resistance of a JFET at zero gate bias is given by the standard relation: R DS(on) = V P / I DSS ...

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...

Online Simulator for ASK, FSK, and PSK

Interactive Digital Signal Processing (DSP) Tutorial and Simulator for ASK, FSK, and BPSK modulation techniques. Try our new Digital Signal Processing Simulator!   •   Interactive ASK, FSK, and BPSK tools updated for 2025. Start Now Digital Modulation Visualizer: ASK, FSK, & BPSK Simulator Learn and visualize binary modulation techniques (ASK, FSK, BPSK) in real-time with adjustable carrier and sampling parameters. Perfect for DSP students and engineers. 📡 ASK Simulator 📶 FSK Simulator 🎚️ BPSK Simulator 📚 More Topics ASK Modulator FSK Modulator BPSK Modulator More Topics 1. ASK (Amplitude Shift Keying) Simulat...

Constellation Diagrams of ASK, PSK, and FSK (with MATLAB Code + Simulator)

Constellation Diagrams: ASK, FSK, and PSK Comprehensive guide to signal space representation, including interactive simulators and MATLAB implementations. 📘 Overview 🧮 Simulator ⚖️ Theory Q-function 📚 Resources 📂 Other Topics: M-ary PSK & QAM Diagrams ▼ 🧮 Simulator for M-ary PSK Constellation 🧮 Simulator for M-ary QAM Constellation BASK (Binary ASK) Modulation Transmits one of two signals: 0 or -√Eb, where Eb​ is the energy per bit. These signals represent binary 0 and 1. BFSK (Binary FSK) Modulation Transmits one of two signals: +√Eb​ (On the y-axis, the phas...

Q-function in BER vs SNR Calculation

Q-function in BER vs. SNR Calculation In the context of Bit Error Rate (BER) and Signal-to-Noise Ratio (SNR) calculations, the Q-function plays a significant role, especially in digital communications and signal processing . What is the Q-function? The Q-function is a mathematical function that represents the tail probability of the standard normal (Gaussian) distribution. Specifically, it is defined as: Q(x) = (1 / sqrt(2Ï€)) ∫â‚“∞ e^(-t² / 2) dt In simpler terms, the Q-function gives the probability that a standard normal random variable exceeds a value x . It is the complementary cumulative distribution function (CCDF) of the standard Gaussian distribution. The Role of the Q-function in BER vs. SNR The Q-function is the standard tool for calculating the Bit Error Rate (BER) in digital communication systems like Binary Phase Shift Keying (BPSK) or Quadrature Phase Shift Keying (QPSK) , where noise follows a Gaussian dis...

1G to 5G Technology - Evolution of Wireless Generations

Cellular wireless evolution Generation Frequency band PHY features Data rate Spectral Eff. (bps/Hz) 1G 850 MHz FDMA, FM N/A N/A 2G 900 MHz, 1.8 GHz TDMA/CDMA, GMSK/QPSK, FEC, PC 10 Kbps < 1 3G 1.8–2.5 GHz CDMA, QAM 1–40 Mbps 1–8 4G 2–8 GHz OFDMA, SC-FDMA, QAM, MIMO-OFDM 100–600 Mbps 15 5G 1–6 GHz mm wave (26–28 GHz) < 1 GHz (massive IoT) visible light? massive MIMO, beamforming D2D, Full duplex, NOMA LDPC and Polar codes OFDM & variants (adapted to extremes?) multi-Gbps several tens Waveform design is the major change between the generations Mobile Wireless Generations Specifications  1G  Voice, Analog traffic, FDMA  2G  Voice, SMS, CS data ...

UGC NET Electronic Science December 2024 Question Paper with Answer Key & Detailed Solutions

Home / UGC NET PYQ / June 2025 Solved UGC NET Electronic Science December 2024 Question Paper with Answer Key and Full Explanations 📥 Download Question Paper (PDF) 2025 2024 2023 2022 2021 2020 Q.1 Answer: Option (3) Q.2 Answer: Option (3) Solution 1. JMP SHORT LABEL Intrasegment (within the same code segment). Direct jump. ❌ Not intersegment indirect. 2. JMP 5000H:2000H Intersegment (far jump because both CS and IP are specified). Direct jump (address is explicitly given). ❌ Not indirect. 3. JMP [2000H] The destination address is taken from memory location 2000H. This is indirect. In 8086, a far indirect jump can use a memory operand containing both IP and CS (depending on operand size), making it an intersegment indirect jump. ✅ Correct answer. 4. JMP [BX] Indirect jump through memory addressed by BX. Usually intrasegment (near indirect jump). ❌ Not in...