Welch’s power spectral density estimate (2024)

Welch’s power spectral density estimate

collapse all in page

Syntax

pxx = pwelch(x)

pxx = pwelch(x,window)

pxx = pwelch(x,window,noverlap)

pxx = pwelch(x,window,noverlap,nfft)

[pxx,w] = pwelch(___)

[pxx,f] = pwelch(___,fs)

[pxx,w] = pwelch(x,window,noverlap,w)

[pxx,f] = pwelch(x,window,noverlap,f,fs)

[___] = pwelch(x,window,___,freqrange)

[___] = pwelch(x,window,___,trace)

[___,pxxc] = pwelch(___,'ConfidenceLevel',probability)

[___] = pwelch(___,spectrumtype)

pwelch(___)

Description

example

pxx = pwelch(x) returnsthe power spectral density (PSD) estimate, pxx,of the input signal, x, found using Welch's overlappedsegment averaging estimator. When x is a vector,it is treated as a single channel. When x isa matrix, the PSD is computed independently for each column and storedin the corresponding column of pxx. If x isreal-valued, pxx is a one-sided PSD estimate.If x is complex-valued, pxx isa two-sided PSD estimate. By default, x is dividedinto the longest possible segments to obtain as close to but not exceed8 segments with 50% overlap. Each segment is windowed with a Hammingwindow. The modified periodograms are averaged to obtain the PSD estimate.If you cannot divide the length of x exactlyinto an integer number of segments with 50% overlap, x istruncated accordingly.

example

pxx = pwelch(x,window) usesthe input vector or integer, window, to dividethe signal into segments. If window is a vector, pwelch dividesthe signal into segments equal in length to the length of window.The modified periodograms are computed using the signal segments multipliedby the vector, window. If window isan integer, the signal is divided into segments of length window.The modified periodograms are computed using a Hamming window of length window.

example

pxx = pwelch(x,window,noverlap) uses noverlap samplesof overlap from segment to segment. noverlap mustbe a positive integer smaller than window if window isan integer. noverlap must be a positive integerless than the length of window if window isa vector. If you do not specify noverlap, orspecify noverlap as empty, the default numberof overlapped samples is 50% of the window length.

example

pxx = pwelch(x,window,noverlap,nfft) specifiesthe number of discrete Fourier transform (DFT) points to use in thePSD estimate. The default nfft is the greaterof 256 or the next power of 2 greater than the length of the segments.

[pxx,w] = pwelch(___) returns the normalized frequency vector, w. If pxx is a one-sided PSD estimate, w spans the interval [0,π] if nfft is even and [0,π) if nfft is odd. If pxx is a two-sided PSD estimate, w spans the interval [0,2π).

example

[pxx,f] = pwelch(___,fs) returns a frequency vector, f, in cycles per unit time. The sample rate, fs, is the number of samples per unit time. If the unit of time is seconds, then f is in cycles/sec (Hz). For real–valued signals, f spans the interval [0,fs/2] when nfft is even and [0,fs/2) when nfft is odd. For complex-valued signals, f spans the interval [0,fs). fs must be the fifth input to pwelch. To input a sample rate and still use the default values of the preceding optional arguments, specify these arguments as empty, [].

[pxx,w] = pwelch(x,window,noverlap,w) returns the two-sided Welch PSD estimates at the normalized frequencies specified in the vector, w. The vector w must contain at least two elements, because otherwise the function interprets it as nfft.

[pxx,f] = pwelch(x,window,noverlap,f,fs) returns the two-sided Welch PSD estimates at the frequencies specified in the vector, f. The vector f must contain at least two elements, because otherwise the function interprets it as nfft. The frequencies in f are in cycles per unit time. The sample rate, fs, is the number of samples per unit time. If the unit of time is seconds, then f is in cycles/sec (Hz).

example

[___] = pwelch(x,window,___,freqrange) returnsthe Welch PSD estimate over the frequency range specified by freqrange.Valid options for freqrange are: 'onesided', 'twosided',or 'centered'.

example

[___] = pwelch(x,window,___,trace) returnsthe maximum-hold spectrum estimate if trace isspecified as 'maxhold' and returns the minimum-holdspectrum estimate if trace is specified as 'minhold'.

example

[___,pxxc] = pwelch(___,'ConfidenceLevel',probability) returnsthe probability×100%confidence intervals for the PSD estimate in pxxc.

example

[___] = pwelch(___,spectrumtype) returns the PSD estimate if spectrumtype is specified as 'psd' and returns the power spectrum if spectrumtype is specified as 'power'.

example

pwelch(___) with no outputarguments plots the Welch PSD estimate in the current figure window.

Examples

collapse all

Welch Estimate Using Default Inputs

Open Live Script

Obtain the Welch PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/4 rad/sample with additive N(0,1) white noise.

Create a sine wave with an angular frequency of π/4 rad/sample with additive N(0,1) white noise. Reset the random number generator for reproducible results. The signal has a length Nx=320 samples.

rng defaultn = 0:319;x = cos(pi/4*n)+randn(size(n));

Obtain the Welch PSD estimate using the default Hamming window and DFT length. The default segment length is 71 samples and the DFT length is the 256 points yielding a frequency resolution of 2π/256 rad/sample. Because the signal is real-valued, the periodogram is one-sided and there are 256/2+1 points. Plot the Welch PSD estimate.

pxx = pwelch(x);pwelch(x)

Welch’s power spectral density estimate (1)

Repeat the computation.

  • Divide the signal into sections of length nsc=Nx/4.5. This action is equivalent to dividing the signal into the longest possible segments to obtain as close to but not exceed 8 segments with 50% overlap.

  • Window the sections using a Hamming window.

  • Specify 50% overlap between contiguous sections

  • To compute the FFT, use max(256,2p) points, where p=log2nsc.

Verify that the two approaches give identical results.

Nx = length(x);nsc = floor(Nx/4.5);nov = floor(nsc/2);nff = max(256,2^nextpow2(nsc));t = pwelch(x,hamming(nsc),nov,nff);maxerr = max(abs(abs(t(:))-abs(pxx(:))))
maxerr = 0

Divide the signal into 8 sections of equal length, with 50% overlap between sections. Specify the same FFT length as in the preceding step. Compute the Welch PSD estimate and verify that it gives the same result as the previous two procedures.

ns = 8;ov = 0.5;lsc = floor(Nx/(ns-(ns-1)*ov));t = pwelch(x,lsc,floor(ov*lsc),nff);maxerr = max(abs(abs(t(:))-abs(pxx(:))))
maxerr = 0

Welch Estimate Using Specified Segment Length

Open Live Script

Obtain the Welch PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/3 rad/sample with additive N(0,1) white noise.

Create a sine wave with an angular frequency of π/3 rad/sample with additive N(0,1) white noise. Reset the random number generator for reproducible results. The signal has 512 samples.

rng defaultn = 0:511;x = cos(pi/3*n)+randn(size(n));

Obtain the Welch PSD estimate dividing the signal into segments 132 samples in length. The signal segments are multiplied by a Hamming window 132 samples in length. The number of overlapped samples is not specified, so it is set to 132/2 = 66. The DFT length is 256 points, yielding a frequency resolution of 2π/256 rad/sample. Because the signal is real-valued, the PSD estimate is one-sided and there are 256/2+1 = 129 points. Plot the PSD as a function of normalized frequency.

segmentLength = 132;[pxx,w] = pwelch(x,segmentLength);plot(w/pi,10*log10(pxx))xlabel('\omega / \pi')

Welch’s power spectral density estimate (2)

Welch Estimate Specifying Segment Overlap

Open Live Script

Obtain the Welch PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/4 rad/sample with additive N(0,1) white noise.

Create a sine wave with an angular frequency of π/4 rad/sample with additive N(0,1) white noise. Reset the random number generator for reproducible results. The signal is 320 samples in length.

rng defaultn = 0:319;x = cos(pi/4*n)+randn(size(n));

Obtain the Welch PSD estimate dividing the signal into segments 100 samples in length. The signal segments are multiplied by a Hamming window 100 samples in length. The number of overlapped samples is 25. The DFT length is 256 points yielding a frequency resolution of 2π/256 rad/sample. Because the signal is real-valued, the PSD estimate is one-sided and there are 256/2+1 points.

segmentLength = 100;noverlap = 25;pxx = pwelch(x,segmentLength,noverlap);plot(10*log10(pxx))

Welch’s power spectral density estimate (3)

Welch Estimate Using Specified DFT Length

Open Live Script

Obtain the Welch PSD estimate of an input signal consisting of a discrete-time sinusoid with an angular frequency of π/4 rad/sample with additive N(0,1) white noise.

Create a sine wave with an angular frequency of π/4 rad/sample with additive N(0,1) white noise. Reset the random number generator for reproducible results. The signal is 320 samples in length.

rng defaultn = 0:319;x = cos(pi/4*n) + randn(size(n));

Obtain the Welch PSD estimate dividing the signal into segments 100 samples in length. Use the default overlap of 50%. Specify the DFT length to be 640 points so that the frequency of π/4 rad/sample corresponds to a DFT bin (bin 81). Because the signal is real-valued, the PSD estimate is one-sided and there are 640/2+1 points.

segmentLength = 100;nfft = 640;pxx = pwelch(x,segmentLength,[],nfft);plot(10*log10(pxx))xlabel('rad/sample')ylabel('dB / (rad/sample)')

Welch’s power spectral density estimate (4)

Welch PSD Estimate of Signal with Frequency in Hertz

Open Live Script

Create a signal consisting of a 100 Hz sinusoid in additive N(0,1) white noise. Reset the random number generator for reproducible results. The sample rate is 1 kHz and the signal is 5 seconds in duration.

rng defaultfs = 1000;t = 0:1/fs:5-1/fs;x = cos(2*pi*100*t) + randn(size(t));

Obtain Welch's overlapped segment averaging PSD estimate of the preceding signal. Use a segment length of 500 samples with 300 overlapped samples. Use 500 DFT points so that 100 Hz falls directly on a DFT bin. Input the sample rate to output a vector of frequencies in Hz. Plot the result.

[pxx,f] = pwelch(x,500,300,500,fs);plot(f,10*log10(pxx))xlabel('Frequency (Hz)')ylabel('PSD (dB/Hz)')

Welch’s power spectral density estimate (5)

Maximum-Hold and Minimum-Hold Spectra

Open Live Script

Create a signal consisting of three noisy sinusoids and a chirp, sampled at 200 kHz for 0.1 second. The frequencies of the sinusoids are 1 kHz, 10 kHz, and 20 kHz. The sinusoids have different amplitudes and noise levels. The noiseless chirp has a frequency that starts at 20 kHz and increases linearly to 30 kHz during the sampling.

Fs = 200e3; Fc = [1 10 20]'*1e3; Ns = 0.1*Fs;t = (0:Ns-1)/Fs;x = [1 1/10 10]*sin(2*pi*Fc*t)+[1/200 1/2000 1/20]*randn(3,Ns);x = x+chirp(t,20e3,t(end),30e3);

Compute the Welch PSD estimate and the maximum-hold and minimum-hold spectra of the signal. Plot the results.

[pxx,f] = pwelch(x,[],[],[],Fs);pmax = pwelch(x,[],[],[],Fs,'maxhold');pmin = pwelch(x,[],[],[],Fs,'minhold');plot(f,pow2db(pxx))hold onplot(f,pow2db([pmax pmin]),':')hold offxlabel('Frequency (Hz)')ylabel('PSD (dB/Hz)')legend('pwelch','maxhold','minhold')

Welch’s power spectral density estimate (6)

Repeat the procedure, this time computing centered power spectrum estimates.

[pxx,f] = pwelch(x,[],[],[],Fs,'centered','power');pmax = pwelch(x,[],[],[],Fs,'maxhold','centered','power');pmin = pwelch(x,[],[],[],Fs,'minhold','centered','power');plot(f,pow2db(pxx))hold onplot(f,pow2db([pmax pmin]),':')hold offxlabel('Frequency (Hz)')ylabel('Power (dB)')legend('pwelch','maxhold','minhold')

Welch’s power spectral density estimate (7)

Upper and Lower 95%-Confidence Bounds

Open Live Script

This example illustrates the use of confidence bounds with Welch's overlapped segment averaging (WOSA) PSD estimate. While not a necessary condition for statistical significance, frequencies in Welch's estimate where the lower confidence bound exceeds the upper confidence bound for surrounding PSD estimates clearly indicate significant oscillations in the time series.

Create a signal consisting of the superposition of 100 Hz and 150 Hz sine waves in additive white N(0,1) noise. The amplitude of the two sine waves is 1. The sample rate is 1 kHz. Reset the random number generator for reproducible results.

rng defaultfs = 1000;t = 0:1/fs:1-1/fs;x = cos(2*pi*100*t)+sin(2*pi*150*t)+randn(size(t));

Obtain the WOSA estimate with 95%-confidence bounds. Set the segment length equal to 200 and overlap the segments by 50% (100 samples). Plot the WOSA PSD estimate along with the confidence interval and zoom in on the frequency region of interest near 100 and 150 Hz.

L = 200;noverlap = 100;[pxx,f,pxxc] = pwelch(x,hamming(L),noverlap,200,fs,... 'ConfidenceLevel',0.95);plot(f,10*log10(pxx))hold onplot(f,10*log10(pxxc),'-.')hold offxlim([25 250])xlabel('Frequency (Hz)')ylabel('PSD (dB/Hz)')title('Welch Estimate with 95%-Confidence Bounds')

Welch’s power spectral density estimate (8)

The lower confidence bound in the immediate vicinity of 100 and 150 Hz is significantly above the upper confidence bound outside the vicinity of 100 and 150 Hz.

DC-Centered Power Spectrum

Open Live Script

Create a signal consisting of a 100 Hz sinusoid in additive N(0,1/4) white noise. Reset the random number generator for reproducible results. The sample rate is 1 kHz and the signal is 5 seconds in duration.

rng defaultfs = 1000;t = 0:1/fs:5-1/fs;noisevar = 1/4;x = cos(2*pi*100*t)+sqrt(noisevar)*randn(size(t));

Obtain the DC-centered power spectrum using Welch's method. Use a segment length of 500 samples with 300 overlapped samples and a DFT length of 500 points. Plot the result.

[pxx,f] = pwelch(x,500,300,500,fs,'centered','power');plot(f,10*log10(pxx))xlabel('Frequency (Hz)')ylabel('Magnitude (dB)')grid

Welch’s power spectral density estimate (9)

You see that the power at -100 and 100 Hz is close to the expected power of 1/4 for a real-valued sine wave with an amplitude of 1. The deviation from 1/4 is due to the effect of the additive noise.

Welch PSD Estimate of a Multichannel Signal

Open Live Script

Generate 1024 samples of a multichannel signal consisting of three sinusoids in additive N(0,1) white Gaussian noise. The sinusoids' frequencies are π/2, π/3, and π/4 rad/sample. Estimate the PSD of the signal using Welch's method and plot it.

N = 1024;n = 0:N-1;w = pi./[2;3;4];x = cos(w*n)' + randn(length(n),3);pwelch(x)

Welch’s power spectral density estimate (10)

Input Arguments

collapse all

noverlapNumber of overlapped samples
positive integer | []

Number of overlapped samples, specified as a positive integersmaller than the length of window. If you omit noverlap orspecify noverlap as empty, a value is used toobtain 50% overlap between segments.

nfftNumber of DFT points
max(256,2^nextpow2(length(window))) (default) | integer | []

Number of DFT points, specified as a positive integer. For areal-valued input signal, x, the PSD estimate, pxx haslength (nfft/2+1)if nfft is even, and (nfft+1)/2 if nfft isodd. For a complex-valued input signal,x, thePSD estimate always has length nfft. If nfft isspecified as empty, the default nfft is used.

If nfft is greater than the segment length,the data is zero-padded. If nfft is less thanthe segment length, the segment is wrapped using datawrap tomake the length equal to nfft.

Data Types: single | double

traceTrace mode
'mean' (default) | 'maxhold' | 'minhold'

Trace mode, specified as one of 'mean', 'maxhold',or 'minhold'. The default is 'mean'.

  • 'mean' — returns the Welchspectrum estimate of each input channel. pwelch computesthe Welch spectrum estimate at each frequency bin by averaging thepower spectrum estimates of all the segments.

  • 'maxhold' — returns themaximum-hold spectrum of each input channel. pwelch computesthe maximum-hold spectrum at each frequency bin by keeping the maximumvalue among the power spectrum estimates of all the segments.

  • 'minhold' — returns theminimum-hold spectrum of each input channel. pwelch computesthe minimum-hold spectrum at each frequency bin by keeping the minimumvalue among the power spectrum estimates of all the segments.

Output Arguments

collapse all

More About

collapse all

Welch’s Overlapped Segment Averaging Spectral Estimation

The periodogram is not a consistent estimator of the true power spectral density of a wide-sense stationary process. Welch’s technique to reduce the variance of the periodogram breaks the time series into segments, usually overlapping.

Welch’s method computes a modified periodogram for each segment and then averages these estimates to produce the estimate of the power spectral density. Because the process is wide-sense stationary and Welch’s method uses PSD estimates of different segments of the time series, the modified periodograms represent approximately uncorrelated estimates of the true PSD and averaging reduces the variability.

The segments are typically multiplied by a window function, such as a Hamming window, so that Welch’s method amounts to averaging modified periodograms. Because the segments usually overlap, data values at the beginning and end of the segment tapered by the window in one segment, occur away from the ends of adjacent segments. This guards against the loss of information caused by windowing.

References

[1] Hayes, Monson H. Statistical Digital Signal Processing and Modeling. New York: John Wiley & Sons, 1996.

[2] Stoica, Petre, and Randolph Moses. Spectral Analysis of Signals. Upper Saddle River, NJ: Prentice Hall, 2005.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

expand all

The pwelch function supports single-precision variable-size window inputs for code generation.

The pwelch function supports single-precision inputs.

You can now use the Create Plot Live Editor task to visualize the output of pwelch interactively. You can select different chart types and set optional parameters. The task also automatically generates code that becomes part of your live script.

See Also

Apps

  • Signal Analyzer

Functions

  • periodogram | pmtm | pspectrum

Topics

  • Bias and Variability in the Periodogram
  • Spectral Analysis

MATLAB 命令

您点击的链接对应于以下 MATLAB 命令:

 

请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。

Welch’s power spectral density estimate (11)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

Europe

Asia Pacific

Contact your local office

Welch’s power spectral density estimate (2024)

FAQs

How do you estimate power spectral density using Welch's method? ›

Estimating PSD with the Welch method. The Welch method is another commonly used to estimate PSD from EEG. The basic idea behind the Welch method is to use a moving window technique where the FFT is computed in each window and the PSD is then computed as an average of FFTs over all windows.

When to use Welch's method? ›

Welch's t-test also known as unequal variances t-test is used when you want to test whether the means of two population are equal. This test is generally applied when the there is a difference between the variations of two populations and also when their sample sizes are unequal.

What is the Welch method of resolution? ›

The Welch method is to window the data segments prior to compute the periodogram. The resolution of PSE is determined by the spectral resolution of each segment which is of length L, which is window independent. The windowing processing of the segments is what makes the Welch method a modified periodogram.

What is the formula for Welch's method? ›

Welch PSD Estimate of Signal with Frequency in Hertz

rng default fs = 1000; t = 0:1/fs:5-1/fs; x = cos(2*pi*100*t) + randn(size(t)); Obtain Welch's overlapped segment averaging PSD estimate of the preceding signal.

How do you interpret power spectral density? ›

The power spectral density (PSD) of the signal describes the power present in the signal as a function of frequency, per unit frequency. Power spectral density is commonly expressed in watts per hertz (W/Hz).

In which scenario would it be most appropriate to use a Welch's t-test instead of a student's t-test? ›

If the test of the equality of variances is significant, Welch's t-test should be used instead of Student's t-test because the assumption of equal variances is violated.

What are the advantages of Welch's method? ›

One reason Welch's method improves upon Student's T is that under random sampling, Welch's method satisfies the basic requirement of converging to the correct answer as the sample sizes get large when randomly sampling from nonnormal distributions, even when the sample sizes are unequal.

What is the Welch's test formula? ›

The Welch's t-statistic is calculated as the difference between the sample means divided by the standard error of the difference.

Why do we use power spectral density? ›

A Power Spectral Density (PSD) is the measure of signal's power content versus frequency. A PSD is typically used to characterize broadband random signals. The amplitude of the PSD is normalized by the spectral resolution employed to digitize the signal. For vibration data, a PSD has amplitude units of g2/Hz.

What is the difference between power spectrum and power spectral density? ›

Therefore, while the power spectrum calculates the area under the signal plot using the discrete Fourier Transform, the power spectrum density assigns units of power to each unit of frequency and thus, enhances periodicities.

How do you convert power spectrum to power spectral density? ›

And so to get power spectral density, we divide the power spectrum by the equivalent noise bandwidth. We know power spectrum is the absolute value of the FFT squared divided by N^2. And this is the equation for the equivalent noise bandwidth for an arbitrary window.

When to use the Welch method? ›

It is used in physics, engineering, and applied mathematics for estimating the power of a signal at different frequencies. The method is based on the concept of using periodogram spectrum estimates, which are the result of converting a signal from the time domain to the frequency domain.

What is Welch's method algorithm? ›

Welch's method [297] (also called the periodogram method) for estimating power spectra is carried out by dividing the time signal into successive blocks, forming the periodogram for each block, and averaging. is the rectangular window, the periodograms are formed from non-overlapping successive blocks of data.

What is Welch's averaging method? ›

The Welch method reduces the variance of the periodogram method by averaging. This method first divides a time series into overlapping subsequences by applying a window to each subsequence and then averaging the periodogram of each subsequence.

How do you calculate power density? ›

The Calculation of power density is pretty simple – composed of 2 steps:
  1. Calculate the area of a beam using the radius in cm.
  2. Divide the beam's power by that area.

What is the formula for power spectral density using FFT? ›

fs = 1000; t = 0:1/fs:1-1/fs; x = cos(2*pi*100*t) + randn(size(t)); Obtain the periodogram using fft . The signal is real-valued and has even length. Because the signal is real-valued, you only need power estimates for the positive or negative frequencies.

How is spectral density measured? ›

PSD is typically measured in units of Vrms2 /Hz or Vrms/rt Hz , where "rt Hz" means "square root Hertz". Alternatively, PSD can be expressed in units of dBm/Hz. On a spectrum analyzer such as the PSA, ESA, 856XE/EC or 859XE, power spectral density can be measured with the noise marker.

How power density is determined? ›

In this context, power density is commonly defined as power per swept volume or brake horsepower per cubic centimeter. This measure is derived from the internal capacity of the engine, providing insight into its power output relative to its internal volume rather than its external size.

Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 5950

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.