Skip to main content

Bartlett Method in MATLAB


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











Copy the code from here 



Further Reading

People are good at skipping over material they already know!

View Related Topics to







Admin & Author: Salim

s

  Website: www.salimwireless.com
  Interests: Signal Processing, Telecommunication, 5G Technology, Present & Future Wireless Technologies, Digital Signal Processing, Computer Networks, Millimeter Wave Band Channel, Web Development
  Seeking an opportunity in the Teaching or Electronics & Telecommunication domains.
  Possess M.Tech in Electronic Communication Systems.


Contact Us

Name

Email *

Message *

Popular Posts

Antenna Gain-Combining Methods - EGC, MRC, SC, and RMSGC

📘 Overview 🧮 Equal gain combining (EGC) 🧮 Maximum ratio combining (MRC) 🧮 Selective combining (SC) 🧮 Root mean square gain combining (RMSGC) 🧮 Zero-Forcing (ZF) Combining 🧮 MATLAB Code 📚 Further Reading  There are different antenna gain-combining methods. They are as follows. 1. Equal gain combining (EGC) 2. Maximum ratio combining (MRC) 3. Selective combining (SC) 4. Root mean square gain combining (RMSGC) 5. Zero-Forcing (ZF) Combining  1. Equal gain combining method We add the correlated data streams from different antennas in the equal gain combining method. Then we multiply the resultant data with (1/(number of antennas)) For example, for two antenna gain-combining  If the received symbols are y1 and y2, then  Equal combing gain, y_egc = 0.5 * (y1 + y2) 2. Maximum ratio combining method We multiply the individual data streams with weights in the maximum ratio combining method. More weightage is multipli...

Comparisons among ASK, PSK, and FSK | And the definitions of each

📘 Overview 🧮 Simulator 🧮 Noise Sensitivity, Bandwidth, Complexity, etc. 🧮 MATLAB Codes 🧮 Some Questions and Answers 📚 Further Reading Modulation ASK, FSK & PSK Constellation MATLAB Simulink MATLAB Code Comparisons among ASK, PSK, and FSK    Comparisons among ASK, PSK, and FSK   Simulator for Calculating Bandwidth of ASK, FSK, and PSK The baud rate represents the number of symbols transmitted per second. Both baud rate and bit rate are same for binary ASK, FSK, and PSK. Select Modulation Type: ASK FSK PSK Baud Rate or Bit Rate (bps): Frequency Deviation (Hz) for FSK: Calculate Bandwidth Comparison among ASK,  FSK, and PSK Performance Comparison: 1. Noise Sensitivity:    - ASK is the most sensitive to noise due to its r...

Constellation Diagrams of ASK, PSK, and FSK

📘 Overview 🧮 Simulator for constellation diagrams of ASK, FSK, and PSK 🧮 Theory 🧮 MATLAB Codes 📚 Further Reading 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 phase shift of 90 degrees with respect to the x-axis, which is also termed phase offset ) or √Eb (on x-axis), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BPSK (Binary PSK) Modulation: Transmits one of two signals: +√Eb​ or -√Eb (they differ by 180 degree phase shift), where Eb​ is the energy per bit. These signals represent binary 0 and 1.    Simulator for BASK, BPSK, and BFSK Constellation Diagrams SNR (dB): 15 Add A...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...

📘 Overview of BER and SNR 🧮 Simulator for m-ary QAM and m-ary PSK 🧮 MATLAB Codes 📚 Further Reading Modulation Constellation Diagrams BER vs. SNR BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ... What is Bit Error Rate (BER)? The abbreviation BER stands for bit error rate, which indicates how many corrupted bits are received (after the demodulation process) compared to the total number of bits sent in a communication process. It is defined as,  In mathematics, BER = (number of bits received in error / total number of transmitted bits)  On the other hand, SNR refers to the signal-to-noise power ratio. For ease of calculation, we commonly convert it to dB or decibels.   What is Signal the signal-to-noise ratio (SNR)? SNR = signal power/noise power (SNR is a ratio of signal power to noise power) SNR (in dB) = 10*log(signal power / noise power) [base 10] For instance,...

RMS Delay Spread, Excess Delay Spread and Multi-path ...

📘 Overview 🧮 Multipath Components or MPCs 🧮 Excess Delay spread 🧮 Power delay Profile 🧮 RMS Delay Spread 🧮 Simulator for Calculating RMS Delay Spread 🧮 Why is there significant multipath in the case of very high frequencies? 🧮 Why RMS Delay Spread is essential for wireless communication? 🧮 Why the Power Delay Profile is essential? 🧮 MATLAB Codes 📚 Further Reading Signal Processing RMS Delay Spread, Excess Delay Spread, and Multipath... RMS Delay Spread, Excess Delay Spread, and Multipath (MPCs) The fundamental distinction between wireless and wired connections is that in wireless connections signal reaches at receiver thru multipath signal propagation rather than directed transmission like co-axial cable. Wireless Communication has no set communication path between the transmitter and the receiver. The line of sight path, also known as the LOS path, is the shortest and most direc...

MATLAB Code for Pulse Amplitude Modulation (PAM) and Demodulation

📘 Overview & Theory 🧮 MATLAB Code 1 🧮 MATLAB Code 2 🧮 MATLAB Code for Pulse Amplitude Modulation and Demodulation of Digital data 🧮 Other Pulse Modulation Techniques (e.g., PWM, PPM, DM, and PCM) 📚 Further Reading   Pulse Amplitude Modulation (PAM) & Demodulation MATLAB Script clc; clear all; close all; fm= 10; % frequency of the message signal fc= 100; % frequency of the carrier signal fs=1000*fm; % (=100KHz) sampling frequency (where 1000 is the upsampling factor) t=0:1/fs:1; % sampling rate of (1/fs = 100 kHz) m=1*cos(2*pi*fm*t); % Message signal with period 2*pi*fm (sinusoidal wave signal) c=0.5*square(2*pi*fc*t)+0.5; % square wave with period 2*pi*fc s=m.*c; % modulated signal (multiplication of element by element) subplot(4,1,1); plot(t,m); title('Message signal'); xlabel ('Time'); ylabel('Amplitude'); subplot(4,1,2); plot(t,c); title('Carrier signal'); xlabel('Time'); ylabel('Amplitu...

Constellation Diagram of FSK in Detail

📘 Overview 🧮 Simulator for constellation diagram of FSK 🧮 Theory 🧮 MATLAB Code 📚 Further Reading   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 SNR (dB): ...