Help with pwelch function (windowing)

6 vues (au cours des 30 derniers jours)
Nathan P
Nathan P le 27 Mar 2013
Hello,
I am trying to use the pwelch command to calculate energy spectra of a 2D boundary profile which consists of 61 points. (with uniform spatial distribution). I zero-pad and detrend the data to remove any mean and extend it to 64 points. We take repeated scans of the boundary,and plan to calculate the spectrum as above, and then average the spectrum over the number of scans.
I am confused with respect to the actual workings of the pwelch function - can someone tell me what the difference in the output would be if either of these commands are used? (Spac = spacing between corresponding points.)
[pxx,f1]= pwelch(upadded,64,0,64,(1/spac));
[pxx, f1] = pwelch(upadded,ones(1,64),0,64,(1/spac));
Am I right in saying that the second line implies that there is essentially no windowing being performed? The results don't vary a lot when I use either, and that is leading to some confusion. Any help is appreciated.

Réponse acceptée

Wayne King
Wayne King le 27 Mar 2013
Modifié(e) : Wayne King le 27 Mar 2013
You are essentially correct, but a few points here:
pwelch() is used for overlapped segment averaging. Here you have a data vector of 61 points, so by using a window of 61 points (you actually use a window longer than your input signal, which you shouldn't do. You don't base your window length on the NFFT), you're not getting any overlapped averaging here, so just use periodogram.
[pxx,f] = periodogram(upadded,hamming(length(upadded)),64,1/spac);
[pxx1,f] = periodogram(upadded,[],64,1/spac);
The first periodogram is a modified periodogram using a Hamming window. The second uses a rectangular window.
This is very short data record, so you may want to increase your padding out to 128.

Plus de réponses (1)

Nathan P
Nathan P le 28 Mar 2013
Thanks for the prompt response Wayne! That was really helpful, I have modified my mfile to limit the window size to the actual input signal. I had a couple of follow up questions though. I tried using the periodogram function as you suggested:
1) [pxx,f] = periodogram(upadded,hamming(length(upadded)),64,1/spac);
This gives the exact same output as:
2) [pxx,f1]= pwelch(upadded,length(upadded),0,64,(1/spac));
which is not surprising.
Can you please tell me how the syntax:
3) [pxx, f1] = pwelch(upadded,ones(1,length(upadded)),0,64,(1/spac)); would give a different output, as opposed to the two above? (And if so, which is the right way to do it?) The spectrum I get by using (3) has a slightly shallower slope.
Here is what Matlab help says regarding inputting the 'Window' parameter as a vector as opposed to an integer.
-------
Pxx = PWELCH(X,WINDOW), when WINDOW is a vector, divides X into
overlapping sections of length equal to the length of WINDOW, and then
windows each section with the vector specified in WINDOW. If WINDOW is
an integer, X is divided into sections of length equal to that integer
value, and a Hamming window of equal length is used.
-------

Community Treasure Hunt

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

Start Hunting!

Translated by