Skip to main content

Bartlett Method in MATLAB (with Simulator)


Estimate PSD by segmenting the signal into \(K\) non-overlapping segments, computing periodograms, and averaging:

\[ P_x(f) = \frac{1}{K \cdot M} \sum_{m=0}^{K-1} \left| \sum_{n=0}^{M-1} x_k[n] e^{-j 2 \pi f n} \right|^2 \]

Where \(x_k[n]\) is the m-th segment, \(K\) is number of segments, and \(M\) is the segment length.


Steps to calculate Spectral power density using Bartlett Method

  1. 'M' is the length of each segment for the Bartlett method, set to 100 samples.
  2. 'K' is the number of segments obtained by dividing the total number of samples N by the segment length 'M'.
  3. psd_bartlett_broadband is initialized to store the accumulated periodogram.
  4. For each segment k, x_k extracts the k-th segment of the broadband signal.
  5. P_k computes the periodogram of the k-th segment using the FFT.
  6. The periodograms are accumulated and averaged over all segments.
  7. The PSD is plotted in dB/Hz by converting the power values to decibels using 10 * log10.

 

MATLAB Script


clc;
clear;
close all;

% Parameters
fs = 1000; % Sampling frequency
t = 0:1/fs:1-1/fs; % Time vector
N = length(t); % Number of samples

% Generate synthetic broadband ARMA process
arma_order = [2, 2]; % ARMA(p,q) order
a = [1, -0.75, 0.5]; % AR coefficients
b = [1, 0.4, 0.3]; % MA coefficients
%broadband_signal = filter(b, a, randn(size(t)));
% Generate sinusoids with different frequencies
frequencies = [50, 150, 300, 450]; % Frequencies in Hz
amplitudes = [1, 0.8, 0.6, 0.4]; % Amplitudes
broadband_input = zeros(size(t));

for i = 1:length(frequencies)
    broadband_input = broadband_input + amplitudes(i) * sin(2*pi*frequencies(i)*t);
end

% Add noise for realism (optional)
broadband_signal = broadband_input + 0.2*randn(size(t));
broadband_signal = filter(b, a, broadband_signal);

% Generate synthetic narrowband process
f0 = 50; % Center frequency of narrowband process
narrowband_signal = sin(2*pi*f0*t) + 0.5*randn(size(t));

% Parameters for Bartlett method
M = 100; % Length of each segment
K = N / M; % Number of segments

% Initialize the PSD estimate for broadband signal
psd_bartlett_broadband = zeros(1, M);

% Loop over each segment for broadband signal
for k = 1:K
    % Extract the k-th segment
    x_k = broadband_signal((k-1)*M + (1:M));

    % Compute the periodogram of the k-th segment
    P_k = abs(fft(x_k, M)).^2 / M;

    % Accumulate the periodogram
    psd_bartlett_broadband = psd_bartlett_broadband + P_k;
end

% Average the periodograms
psd_bartlett_broadband = psd_bartlett_broadband / K;

% Initialize the PSD estimate for narrowband signal
psd_bartlett_narrowband = zeros(1, M);

% Loop over each segment for narrowband signal
for k = 1:K
    % Extract the k-th segment
    x_k = narrowband_signal((k-1)*M + (1:M));

    % Compute the periodogram of the k-th segment
    P_k = abs(fft(x_k, M)).^2 / M;

    % Accumulate the periodogram
    psd_bartlett_narrowband = psd_bartlett_narrowband + P_k;
end

% Average the periodograms
psd_bartlett_narrowband = psd_bartlett_narrowband / K;

% Frequency axis
f = (0:M-1)*(fs/M);

% Plot the PSD for broadband signal
figure;
plot(f(1:50), 10*log10(psd_bartlett_broadband(1:50)));
title('Power Spectral Density (Bartlett Method) - Broadband Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');

% Plot the PSD for narrowband signal
figure;
plot(f(1:50), 10*log10(psd_bartlett_narrowband(1:50)));
title('Power Spectral Density (Bartlett Method) - Narrowband Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
web('https://www.salimwireless.com/search?q=spectral%20estimation', '-browser');
 

Output

Bartlett Narrowband PSD
Bartlett Method PSD for Narrowband Signal
 
Bartlett Broadband PSD
Bartlett Method PSD for Broadband Signal
 

Further Reading

  1. Periodogram in MATLAB
  2. Welch Method for Spectral Estimation in MATLAB
  3. Correlogram in MATLAB
  4. Power Spectral Density Calculation Using Simple FFT in MATLAB
  5. Spectral Estimation Methods - Periodogram, Correlogram, Welch, Bartlett ... (Theory)

Online Interactive Simulator for PSD Estimation using Bartlett Method

Parameters


Base Signal

Input Signal

AWGN Noise

Output

Upload CSV and See Output



Input Signal

Output

Spectral Density Estimation Methods

Estimating Spectral Density: The Windowed Periodogram

To accurately determine the Power Spectral Density (PSD) of a discrete signal, engineers frequently utilize the windowed periodogram. This approach applies a specific weighting function to raw data to mitigate "spectral leakage"—a phenomenon where energy from a primary frequency "seeps" into adjacent bins, distorting the analysis.

Core Periodogram Principles

The most basic form of PSD estimation is the traditional periodogram, derived directly from the Discrete-Time Fourier Transform (DTFT). In its raw state, the periodogram is defined as:

\[ P_x(f) = \frac{1}{N} \left| \sum_{n=0}^{N-1} x[n] e^{-j 2 \pi f n} \right|^2 \]

Where \(x[n]\) represents the discrete samples and \(N\) is the total sample size. Without modification, this method is highly susceptible to leakage errors due to the abrupt truncation of the signal.

Improving Precision via Windowing

By multiplying the signal by a window function \(w[n]\) before processing, we taper the edges of the data, leading to a more accurate spectrum:

\[ P_x(f) = \frac{1}{N \cdot U} \left| \sum_{n=0}^{N-1} x[n] w[n] e^{-j 2 \pi f n} \right|^2 \]

To keep the total power consistent, we use a normalization constant \(U\):

\[ U = \frac{1}{N} \sum_{n=0}^{N-1} |w[n]|^2 \]

Popular Windowing Functions

  • Rectangular: A simple truncation; treats all samples equally but offers minimal leakage protection.
  • Hamming: Uses a cosine-based curve (\(0.54 - 0.46 \cos\)) to suppress the "sidelobes" of the frequency response.
  • Hann: Similar to Hamming but provides a smoother fade-out to zero at the boundaries.
  • Blackman: Adds extra terms to the sequence to further minimize sidelobes at the cost of a wider central peak.

Alternative PSD Estimation Techniques

1. The Correlogram Method

Based on the Wiener-Khinchin theorem, this technique computes the Fourier transform of the signal’s estimated autocorrelation sequence \(R_x[k]\):

\[ P_x(f) = \sum_{k=-(N-1)}^{N-1} R_x[k] e^{-j 2 \pi f k} \]

To ensure the PSD never yields negative values, a biased estimate (dividing by \(N\)) is standard practice.

2. Bartlett’s Method (Averaging)

Bartlett’s approach reduces statistical noise (variance) by splitting the signal into \(M\) non-overlapping segments and averaging their periodograms:

\[ P_x(f) = \frac{1}{M \cdot N} \sum_{m=0}^{M-1} \left| \sum_{n=0}^{N-1} x_m[n] e^{-j 2 \pi f n} \right|^2 \]

Trade-off: While it reduces variance by a factor of \(M\), it lowers frequency resolution because each segment is shorter than the original data.

3. Blackman-Tukey Method

This method applies a window to the autocorrelation sequence rather than the raw signal. By smoothing the correlation lags before the Fourier transform, it produces a much cleaner estimate.

\[ P_x(f) = \sum_{k=-K}^{K} R_x[k] w[k] e^{-j 2 \pi f k} \]

4. Welch’s Method: The Industry Standard

An evolution of Bartlett’s method, Welch’s technique allows segments to overlap (usually by 50%) and applies a window function to each segment before processing.

\[ P_x(f) = \frac{1}{K \cdot L \cdot U} \sum_{k=0}^{K-1} \left| \sum_{n=0}^{L-1} x_k[n] w[n] e^{-j 2 \pi f n} \right|^2 \]

Welch’s method is widely considered the best balance between noise reduction and spectral leakage prevention.



Contact Us

Name

Email *

Message *

Popular Posts

MATLAB Code for BER performance of QPSK with BPSK, 4-QAM, 16-QAM, 64-QAM, 256-QAM, etc

📘 Overview 🧮 MATLAB Codes 🧮 Online Simulator for Calculating BER of M-ary PSK and QAM 🧮 QPSK vs BPSK and QAM: A Comparison of Modulation Schemes in Wireless Communication 🧮 Are QPSK and 4-PSK same? 📚 Further Reading   QPSK offers double the data rate of BPSK while maintaining a similar bit error rate at low SNR when Gray coding is used. It shares spectral efficiency with 4-QAM and can outperform 4-QAM or 16-QAM in very noisy channels. QPSK is widely used in practical wireless systems, often alongside QAM in adaptive modulation schemes [Read more...] What is the Gray Code? Gray Code: Gray code is a binary numeral system where two successive values differ in only one bit. This property is called the single-bit difference or unit distance code. It is also known as reflected binary code. Let's convert binary 111 to Gray code: Binary bits: B = 1 1 1 Apply the rule: G[0] = B[0] = 1...

FFT Butterfly Method Explained (with Simulations)

4-Point FFT Using Butterfly Method Given: x[n] = {0, 1, 2, 3} Step 1: Split into Even & Odd Even indices: x e = {x[0], x[2]} = {0, 2} Odd indices: x o = {x[1], x[3]} = {1, 3} Step 2: 2-point DFT For any {a, b}: DFT = {a + b, a - b} Even Part (E): {0+2, 0-2} = {2, -2} Odd Part (O): {1+3, 1-3} = {4, -2} Step 3: Combine Using Butterfly X[k] = E[k] + W 4 k O[k] X[k + 2] = E[k] - W 4 k O[k] Twiddle Factors (N=4): W 4 0 = 1, W 4 1 = -j Final Calculations: X[0] = E[0] + W 4 0 O[0] = 2 + (1)(4) = 6 X[2] = E[0] - W 4 0 O[0] = 2 - (1)(4) = -2 X[1] = E[1] + W 4 1 O[1] = -2 + (-j)(-2) = -2 + 2j X[3] = E[1] - W 4 1 O[1] = -2 - (-j)(-2) = -2 - 2j Final Answer: X[k] = {6, -2 + 2j, -2, -2 - 2j} 8-Point FFT Using Butterfly Method Given: x[n] = {0,1,2,3,4,5,6,7} Step 1: Split into Bit-Reversed Order To perform DIT-FFT, split the 8 points into pairs of two: Group A: {x[0], x[4]} = {0, 4}...

MATLAB Code for QPSK Modulation and Demodulation

📘 Overview 🧮 MATLAB Codes 🧮 Theory 🧮 BER performance of QPSK with BPSK, 4-QAM, 16-QAM, 64-QAM, 256-QAM, etc 📚 Further Reading QPSK Passband Signal Generation Spectral Efficiency in QPSK   Quadrature Phase Shift Keying (QPSK) is a digital modulation scheme that conveys two bits per symbol by changing the phase of the carrier signal. Each pair of bits is mapped to one of four possible phase shifts: 0°, 90°, 180°, or 270° 00  ===> 0 degree phase shift of carrier signal 01  ===> 90 degree 11  ===> 180 degree 10  ===> 270 degree   MATLAB Script clc; clear all; close all; clc; M = 4; data = randi([0 (M-1)], 1000, 1); Phase = 0; modData=pskmod(data,M,Phase); figure(1); scatterplot(modData); channelAWGN = 15; rxData2 = awgn(modData, channelAWGN); figure(2); scatterplot(rxData2); demodData = pskdemod(rxData2,M,Phase);   Result data 1 0 2 2 0 2 1 . . . modData -1.0...

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

OFDM Symbols and Subcarriers Explained

This article explains how OFDM (Orthogonal Frequency Division Multiplexing) symbols and subcarriers work. It covers modulation, mapping symbols to subcarriers, subcarrier frequency spacing, IFFT synthesis, cyclic prefix, and transmission. Step 1: Modulation First, modulate the input bitstream. For example, with 16-QAM , each group of 4 bits maps to one QAM symbol. Suppose we generate a sequence of QAM symbols: s0, s1, s2, s3, s4, s5, …, s63 Step 2: Mapping Symbols to Subcarriers Assume N sub = 8 subcarriers. Each OFDM symbol in the frequency domain contains 8 QAM symbols (one per subcarrier): Mapping (example) OFDM symbol 1 → s0, s1, s2, s3, s4, s5, s6, s7 OFDM symbol 2 → s8, s9, s10, s11, s12, s13, s14, s15 … OFDM sym...

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 More Topics 1. ASK (Amplitude Shift Keying) Simulat...

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

MATLAB Code for OTFS (Orthogonal Time Frequency Space)

MATLAB Code for OTFS (Orthogonal Time Frequency Space) %% Clear workspace clc; clear; close all ; %% Step 1: OTFS Parameters N_delay = 4; % Number of delay bins (rows) N_doppler = 4; % Number of Doppler bins (columns) N_sym = N_delay * N_doppler; modOrder = 4; % QPSK SNR_dB = 20; % Noise level %% Step 2: Generate random data symbols data = randi([0 modOrder-1], N_sym, 1); txSymbols = pskmod(data, modOrder, pi/4); disp( 'Transmitted Delay-Doppler symbols:' ); disp(reshape(txSymbols, N_delay, N_doppler)); %% Step 3: Map Delay-Doppler → Time-Frequency (ISFFT) % ISFFT: Inverse Symplectic Finite Fourier Transform % 1. Take IDFT along Doppler (columns) % 2. Take DFT along Delay (rows) ddSymbols = reshape(txSymbols, N_delay, N_doppler); % Step 3a: IDFT along columns (Doppler) tfGrid = ifft(ddSymbols, N_doppler, 2); %IFFT (accross columns) along Doppler → spreads in time (Delay → Time) %FFT (accross rows)along Delay → spreads in frequency (Delay → Frequency) % Step 3b: DFT along ...