<< pulsewidth | FOSSEE_Signal_Processing_Toolbox | rc2ac >>

FOSSEE_Signal_Processing_Toolbox >> FOSSEE_Signal_Processing_Toolbox > pwelch

# pwelch

Estimate power spectral density of data "x" by the Welch (1967) periodogram/FFT method.

### Syntax

    [spectra, freq] = pwelch(x, y, window, overlap, Nfft, Fs, range, plot_type, detrend, sloppy, results)
    [spectra, Pxx_ci, freq] = pwelch(x, window, overlap, Nfft, Fs, conf, range, plot_type, detrend, sloppy)
    [spectra, Pxx_ci, freq] = pwelch(x, y, window, overlap, Nfft, Fs, conf, range, plot_type, detrend, sloppy, results)

### Parameters

x:

  [non-empty vector] System-input time-series data.

y:

  [non-empty vector] System-output time-series data.

window:

  [real vector] Window-function values between 0 and 1. Default is Hamming.

overlap:

  [real scalar] Segment overlap expressed as a multiple of window or segment length. Default is 0.5.

Nfft:

  [integer scalar] Length of FFT. Default is the length of the "window" vector or the scalar "window" argument.

Fs:

  [real scalar] Sampling frequency (Hertz). Default is 1.0.

conf:

  [real scalar] Confidence level between 0 and 1. Default is 0.95.

range:

  Frequency range of the spectrum. Options are 'half', 'onesided', 'whole', 'twosided', 'shift', 'centerdc'.

plot_type:

  Specifies the type of plot. Options are 'plot', 'semilogx', 'semilogy', 'loglog', 'squared', 'db'. Default is 'plot'.

detrend:

  Specifies how to remove trends from the data. Options are 'no-strip', 'none', 'short', 'mean', 'linear', 'long-mean'. Default is 'long-mean'.

sloppy:

  Adjusts FFT length to the nearest integer power of 2 by zero padding. Default is exact FFT length.

results:

  Specifies what results to return. Options are 'power', 'cross', 'trans', 'coher', 'ypower'. Default is 'power'.

### Description

The `pwelch` function estimates the power spectral density (PSD) of data "x" using the Welch periodogram/FFT method. It supports single-channel and two-channel spectrum analysis, including power spectral density, cross-spectral density, transfer function, and coherence functions.

The data is divided into overlapping segments. Each segment is windowed using the specified window function (e.g., Hamming) and zero-padded to the desired FFT length. The periodogram is computed for each segment, and the PSD is obtained by averaging the periodograms. This averaging reduces the variance of the spectral estimate.

The function also supports confidence interval estimation for the PSD, which is based on the scatter in the periodograms. However, confidence intervals are only available for the power spectrum of "x" and not for cross-power spectra, transfer functions, or coherence functions.

The `pwelch` function provides compatibility with different versions of MATLAB (R11, R12, R14) and their respective default behaviors. It also includes options for customizing the frequency range, plot type, and detrending method.

Notes - The spectral density is scaled so that the area under the spectrum equals the mean square of the data. - The function supports both one-sided and two-sided spectra. For one-sided spectra, contributions from negative frequencies are added to the positive side of the spectrum. - The default window function is Hamming, but other window functions (e.g., Hann, Bartlett) can be used. - Zero-padding increases the frequency resolution but does not improve the accuracy of the spectral estimate. - The function can handle real and complex data. For real data, the default frequency range is 'half'; for complex data, it is 'whole'.

### Examples

    // Compute power spectral density of a signal:
    x = rand(1, 1024);
    [spectra, freq] = pwelch(x)

Report an issue
<< pulsewidth | FOSSEE_Signal_Processing_Toolbox | rc2ac >>