Skip to main content

Comparison of Spectral Estimation Methods in MATLAB: Periodogram, Welch, Bartlett, and More


MATLAB Code 

% MATLAB script to compare different Spectral Estimation Methods using Built-in Functions

% Sample signal: Sine wave with noise
fs = 1000; % Sampling frequency (Hz)
T = 1; % Signal duration (seconds)
t = 0:1/fs:T-1/fs; % Time vector
f_signal = 50; % Signal frequency (Hz)
signal = sin(2*pi*f_signal*t) + 0.5*randn(size(t)); % Sine wave + noise

% Method 1: Periodogram (Using built-in function)
[pxx_periodogram, f_periodogram] = periodogram(signal, [], [], fs);

% Method 2: Bartlett Method (Using built-in pwelch with default settings)
[pxx_bartlett, f_bartlett] = pwelch(signal, [], [], [], fs);

% Method 3: Welch Method (Using built-in pwelch with segment overlap)
segmentLength = 256; % Length of each segment
overlap = 128; % Overlap between segments
[pxx_welch, f_welch] = pwelch(signal, segmentLength, overlap, [], fs);

% Method 4: Blackman-Tukey Method (Using built-in cpsd function with autocorrelation)
% Compute the Cross Power Spectral Density (CPSD) using autocorrelation
[pxx_bartlett_tukey, f_bartlett_tukey] = cpsd(signal, signal, segmentLength, overlap, [], fs);

% Method 5: Correlogram Method (Using xcorr and FFT)
% Compute the full autocorrelation of the signal (unbiased estimator)
autocorr_full = xcorr(signal, 'unbiased'); % Unbiased autocorrelation (lags from -N to +N)
autocorr_full = autocorr_full(length(signal):end); % Keep only positive lags

% Apply a window function (e.g., Hamming) to the autocorrelation
windowed_autocorr_full = autocorr_full .* hamming(length(autocorr_full))';

% Perform FFT of the windowed autocorrelation to get the PSD
N_full = length(windowed_autocorr_full);
fft_autocorr_full = fft(windowed_autocorr_full, N_full);
pxx_correlogram = abs(fft_autocorr_full(1:N_full/2+1)).^2 / fs;

f_correlogram = (0:N_full/2) * (fs/N_full); % Frequency axis for Correlogram

% Plot all the methods in a single figure
figure;

subplot(3,2,1);
plot(f_periodogram, 10*log10(pxx_periodogram));
title('Periodogram');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

subplot(3,2,2);
plot(f_bartlett, 10*log10(pxx_bartlett));
title('Bartlett Method');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

subplot(3,2,3);
plot(f_welch, 10*log10(pxx_welch));
title('Welch Method');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

subplot(3,2,4);
plot(f_bartlett_tukey, 10*log10(pxx_bartlett_tukey));
title('Blackman-Tukey Method');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

subplot(3,2,5);
plot(f_correlogram, 10*log10(pxx_correlogram));
title('Correlogram Method');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

% Adjust layout for the figure
sgtitle('Comparison of Spectral Estimation Methods');
 

Output

 

Further Reading

  1.  


Contact Us

Name

Email *

Message *

Popular Posts

MATLAB Code for Constellation Diagram of QAM configurations such as 4, 8, 16, 32, 64, 128, and 256-QAM

📘 Overview of QAM 🧮 4-QAM MATLAB 🧮 16-QAM MATLAB 🚀 Online Simulator 📂 Other Topics on Constellation Diagrams... ▼ 🧮 MATLAB Code for 4-QAM 🧮 MATLAB Code for 16-QAM 🧮 MATLAB Code for m-ary QAM 🧮 Simulator for m-ary PSK 🧮 Simulator for m-ary QAM 🧮 Overview of Energy per Bit (Eb / N0) 🧮 Simulator for ASK, FSK, and PSK Overview of QAM One of the best-performing modulation techniques is QAM [↗] . Here, we modulate the symbols by varying the carrier signal's amplitude and phase in response to the variation in the message signal (or voltage variation). So, we may say that QAM is a combination of phase and amplitude modulation. Additionally, it performs better than ASK or PSK [↗] . In fact, any constellation for any type of modulatio...

UGC NET Electronic Science Previous Year Question Papers with Solutions

Download Papers and Solutions Exam Pattern Preparation Tips FAQs More Home / Engineering & Other Exams / UGC NET 2026 PYQ 📊 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 2026 - Question Paper Download PDF June 202...

Flat vs Frequency Selective Online Simulator

Flat vs Frequency Selective Online Simulator Channel Type Without Fading Flat Fading Multipaths Nakagami m SNR(dB) Run Simulation Input Signal Signal After Fading Constellation Diagram BER vs SNR Explore Advanced Flat vs Frequency-Selective Fading Simulator Want to see these equations in action? Visualize it. Launch Simulator Tool Flat Fading and Frequency-Selective Fading Effects of Multipath Components and the Nakagami-m Parameter 1. Flat Fading Flat fading occurs when the signal bandwidth is smaller than the channel's coherence bandwidth, meaning that all frequency components of the transmitted signal experience approximately the same fading. It is typically associated with narrowband signals, where the multipath delay spread is small relative to the symbol duration. ...

Orthogonal Time Frequency Space (OTFS) (with MATLAB)

In OTFS (Orthogonal Time Frequency Space) modulation — a scheme designed for high-Doppler and time-varying wireless channels — the terms ISFFT and SFFT are key mathematical transformations used to move between different representation domains. Figure: OTFS block diagram 1. ISFFT — Inverse Symplectic Finite Fourier Transform Purpose: Transforms data symbols from the delay-Doppler domain to the time-frequency domain . \[ X[n, m] = \frac{1}{\sqrt{NM}} \sum_{k=0}^{N-1} \sum_{l=0}^{M-1} x[k, l] \, e^{j2\pi \left( \frac{nk}{N} - \frac{ml}{M} \right)} \] Here, \( N \) is the number of Doppler bins (time slots), and \( M \) is the number of delay bins (subcarriers). The ISFFT maps each data symbol from the delay-Doppler grid (where the channel is sparse and easier to equalize) to the time-frequency grid (where standard multicarrier modulation like OFDM can be applied). 2. SFFT — Symplectic Finite Fourier Transform Purpose: Performs the reverse operation ...

Online Simulator for ASK, FSK, and PSK Signal Generation

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 Demodulation More Topics 1. ASK (Ampli...

Design of CMOS XOR/XNOR Gates

Design of CMOS XOR/XNOR Gates The semiconductor industry has experienced rapid integration of multimedia applications into mobile electronics, leading to very high integration density in CMOS VLSI. As operating frequencies increase, power consumption, speed, silicon area, and reliability become critical considerations. The XOR-XNOR circuits are fundamental building blocks in arithmetic circuits (Full Adders, Multipliers), compressors, comparators, parity checkers, code converters, error-detecting/correcting codes, and phase detectors. Their performance directly impacts the complex circuits they are used in. Design goals include full output voltage swing, low power consumption, reduced transistor count, minimal delay, and simultaneous non-skewed outputs. Static Logic (Static CMOS) Stat...

Random Variable vs. Random Process: Definitions, Examples, and Key Differences

Random Variable vs. Random Process: Definitions, Examples, and Key Differences Random Variable and Random Process In the fields of probability theory and statistics, understanding the distinction between a Random Variable and a Random Process (Stochastic Process) is fundamental. This guide breaks down these concepts with mathematical precision and practical examples. 1. Random Variable (RV) Definition: A Random Variable is a deterministic function that maps each possible outcome of a random experiment to a unique real number. Mathematical Representation A random variable X is defined as a mapping from the sample space S to the set of real numbers ℝ : X : S → ℝ S (Sample Space): The set of all possible outcomes of an experiment. s ∈ S: A specific outcome. X(s): The numerical value asso...