# PSD using MATLAB's $\tt pwelch$ algorithm window length and measure units

When using pwelch algorithm in MATLAB for a signal with $N$ samples,

• Is there a good rule of thumb for determining the length $L$ of the sections (second variable for the function)?

• And assuming my input is a voltage signal , what are the measure units I get for $10\log_{10}(P_{xx})$ where $P_{xx}$ is the output signal?

Is there a good rule of thumb for determining the length $$L$$ of the sections (second variable for the function)?

$$L$$ (or window argument) specifies a window function to apply, prior to FFT computation of the signal. If $$L$$ is a vector, that vector is considered as window coefficients and is applied on (multiplied to) signal, for example:

Pxx=pwelch(x,[0 0 1 2 3 3 2 1 0 ]); % Means compute spectrum of x.*[0 0 1 2 3 3 2 1 0]


if it is an integer, then a Ham. or Han. window with length of $$L$$ is generated and then this Hamming window is applied to the signal:

Pxx=pwelch(x,10); % Means compute spectrum of x.*(10 point hamming window)


pwelch is based on FFT, and since the spectrum (DFT) of segmented signals shows frequency leakage, I think it would depend on how much resolution you you want and how much frequency leakage, you can tolerate, but generally The more longer the window for frequency static signals is the more leakage is reduced. See this great tutorial for more detail:

http://www.fhnw.ch/technik/ime/publikationen/2012/how-to-use-the-fft-and-matlab2019s-pwelch-function-for-signal-and-noise-simulations-and-measurements

A side note for example codes above is that if the length of your signal x is greater than specified length for the window, then your signal is segmented to vectors with length of $$L$$

assuming my input is a voltage signal , what are the measure units I get in the output?

Since your signal is pure voltage (unknown impedance and hence no current (A) is associated), it is not actual "power" or "energy", however you might use $$\mathrm{V}^2/\mathrm{H}z$$ for PSD. This link might shed more light on it: https://en.wikipedia.org/wiki/Spectral_density#Electrical_engineering In case of logarithmic PSD, you've mentioned it is generally regarded as $$\mathrm{dB}/\mathrm{Hz}$$.

• First of all thanks a lot @Mimsaad. I did look at the [wiki link] (en.wikipedia.org/wiki/Spectral_density#Electrical_engineering) you posted prior to my question post and I guess I have to clarify the question(edited). What are the measure units if I take $10*log_{10}(P_{xx})$? is it $\frac{dBv}{Hz}$? or do I have to use sqrt() before the log extraction? – havakok Aug 4 '16 at 6:43
• The answer to this question is already given here: stackoverflow.com/questions/15255632/… – MimSaad Aug 4 '16 at 14:29
• – MimSaad Aug 4 '16 at 14:44
• – MimSaad Feb 25 at 11:32