How to use pwelch for PSD?

조회 수: 140 (최근 30일)
Tran
Tran 2022년 12월 12일
답변: William Rose 2022년 12월 12일
hi everyone, Do you know about pwelch function? I did a lot of searching on google but didn't find any documentation that explains correctly for me to understand. When I want to use the pwelch function, do I have to care about the window or can I leave it at the default. For an example:
If I want to use window for eeg signal, what kind of window can i use for best perform? and what are the parameters passed in?
Hope I don't bother you,
[pb,f] = pwelch(Data(1,:),hamming(256),[],[1 256],128);
[pb,f] = pwelch(Data(1,:),[],[],[],128);
  댓글 수: 2
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 12일
편집: Bora Eryilmaz 2022년 12월 12일
I recommend using pspectrum instead, which is more straighforward to use. It internally uses the Kaiser window, which is controlled by the "Leakage" parameter of the pspectrum command. Kaiser window is pretty optimal when it comes to selecting a window for spectrum computation.

댓글을 달려면 로그인하십시오.

채택된 답변

William Rose
William Rose 2022년 12월 12일
See my recent reply to @vo, here, regarding the use of Welch's method for EEG analysis. You can get identical results using pwelch() or cpsd(). @vo wanted to use cpsd(). You can use pwelch(). Either one is fine.
See my followup comment at the site above for an explanation of the arguments to pwelch() or cpsd(). The default values are a reasonable place to start. A important fundamental concept is that spectrum estimation involves a tradeoff between high frequency resolution and high certainty (i.e. small random errors) in the estimate. The choice of window length is the main determinant of where one sits with regard to this tradeoff. A large value for window length favors high spectral resolution. A small value favors smaller random errors.
"window" can be a vector or an integer. If "window" is a vector, then it is the actual window coefficients, and the window length is the length of this vector. If "window" is an integer, then a Hamming window of the specified length is used. I recommend that you specifiy "window" as an integer, because a Hamming window is fine. You can make "window" be 1/4 or less of the total signal duration.
I recommend that noverlap be 1/2 or 2/3 or 3/4 of window.
I recommend that nfft be equal to window.
The image below, from some lecture notes, illustrates how Welch's method works, with half-overlapped segments. In this example, the original signal has length N=256, window=N/4, noverlap=N/8, nfft=N/4.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by