I was wondering about the influence of phase discontinuities on a power spectrum density calculated with f.e. Welch's method. I know you shouldn't have any phase discontinuities in your signal, but I'm actually not so sure why.

For my own interpretation I made a signal in Matlab:

x= sin(2*pi*100*t)+sin(2*pi*130*t)+sin(2*pi*160*t) +randn(size(t));

mask= t>=0 & t<=0.7 | t>=2.3 & t<=4.4 | t>=4.95 & t<=5.1 | t>=7.13 & t<=8.12 | t>=8.54 & t<=9.84;

and calculated Welch estimation as: pwelch(x_check,[],[],[],fs)

I still see three distinctive peaks in the PSD, so I don't actually know what the problems are with phase discontinuities.


2 Answers 2


Welch estimation is not good for evaluating the spectrum of single tones-- the technique is intended for (and works great for) power spectral density estimation meaning power that is distributed over a bandwidth. The Welch method will have a resolution bandwidth based on the block size used, and the algorithm will convert that to a power/Hz result assuming the power is uniformly distributed over that bandwidth. Since a single tone has no bandwidth, the overall power in that tone will be reduced from what it actually is at that one data point in frequency. For seeing the effect of single tones, a direct FFT spectrum is better suited. I detail this with examples at this other post:

Larger FFT vs multiple averaged FFTs for detecting small CW signals

With that in mind a step in phase versus time, similar to a step in amplitude vs time, will result in very high frequency content as evidenced in the Fourier Transform. To change in time instantly from one point to another (as we would do with a step) implies a high frequency. I don't know the OP's application, but for wireless communication signals, where we are very concerned about keeping our spectrum within a smaller defined bandwidth (spectral efficiency) steps in phase, frequency or amplitude would be really bad toward this goal. This is the motivation for pulse shaping, such as raised-cosine filtering where instead of transmitting signals as square pulses, we taper the signal as slow as possible from one symbol to another. It terms of phase, this is similar to what is done with GMSK instead of MSK: with MSK the frequency steps instantly from one frequency to the next (just as in FSK), and the phase itself (as the integral of frequency) steps abruptly in its trajectory (so not a discontinuous change in that case, but still an abrupt step which results in higher bandwidth). GMSK rounds those changes and results in less spectral occupancy. Evaluating the spectrum of a modulated GMSK signal could be done well using the Welch method where this effect will be clearer, but with single tones as the OP is doing I recommend just looking at the FFT to see the effect.

Demonstrating this I created a sample waveform with a phase step (magnitude is 1 throughout) compared to a gradual phase transition as shown in the plot below:

waveform under test

I computed the spectrum using an FFT, which was properly windowed to eliminate any spectral leakage we would otherwise see from the mismatch in phase between the start and end of the sequence. The result properly represents the comparative spectrum from the phase transition. The frequency centered on 0 represents a carrier frequency and the frequency range is offset from that carrier.

FFT spectrum

Zooming in further we can see the dramatic effect in increasing spectral occupancy by having a phase discontinuity; it takes many more high frequencies to have the waveform transition abruptly from one phase to another. The rate of change in the waveform (either phase or magnitude or both) will determine how much spectrum any particular waveform will need; slower rate means less bandwidth.

FFT spectrum zoomed in

  • 1
    $\begingroup$ Thanks you very much for the explanation. My application is on biomedical signals (EMG), but I tried to show the consequence of concatenating these signals, that's why I use the Welch's method. The figures explain it really well, why I should try a different method! $\endgroup$
    – Stijn
    Commented Mar 4 at 13:19
  • $\begingroup$ Welch method can be good for EMG signals themselves, since your not necessarily looking for single tones there. In general use the Welch method such that the resolution bandwidth is tighter than the occupied bandwidth of the signal being observed (which is impossible to do for a single tone). My other post explains this in more detail. If you want to get insight using single tones, don't use Welch in that case. $\endgroup$ Commented Mar 4 at 14:06
  • $\begingroup$ I was trying to reproduce the plots in your answer to get more familiar with the procedure. Unfortunately, I don't have much experience in this particular field. I set up a signal with fs=1000; t=0:1/fs/1000; and x_sudden=sin(2*pi*1*t) with x_sudden(2500:end)=sin(2*pi*1*t(2500:end)+0.8). I tried to obtain the phase vs samples plot by using hilbert(x_sudden) and than take the angle and unwrap the angle, but that won't result in step function plot as is shown? Furhtermore, I have windowed the signal with a Hann function as x_sudden(1:n/2)=x_sudden(1:n/2).*hann(length(x_sudden). Can I get a hint? $\endgroup$
    – Stijn
    Commented Mar 5 at 15:05
  • $\begingroup$ No need for creating real sines and then using Hilbert; describe the magnitude and phase vs time that you want with complex numbers directly (as $A[n]e^{j\phi[n]}$). We don’t do coding help on this site and they discourage ongoing discussion in the comments—- if you get stuck with a signal processing detail, feel free to add that as another question. $\endgroup$ Commented Mar 5 at 18:25

Phase discontinuities result in spectral leakage. This is because, at any point where there otherwise would've been energy at frequency $\omega_{0}$, there is now energy at some other frequency $\omega$. The spectral leakage doesn't necessarily need to be concentrated at high frequencies, but the spectrum will be spread out.

In terms of power spectral densities, if there is leakage in the spectrum, there is leakage in the PSD, short of using some fancy tricks that require a priori knowledge of the signal or just dumb luck. There are two explanations I see for this, with each one being related to one of the two definitions of the PSD. The first definition of the PSD is

\begin{equation} \phi(\omega) = \lim_{N\rightarrow\infty}E\left[ \frac{1}{N}\left|\sum_{t=0}^{N}y(t)e^{-j\omega t}\right|^{2} \right] \end{equation}

As we can see, the PSD is related to the spectrum through a magnitude squared operation. So, if there is spectral leakage in the spectrum, there will be leakage in the PSD.

The second definition of the PSD is

\begin{equation} \phi(\omega) = \sum_{k=-\infty}^{\infty}r(k)e^{-j\omega k} \end{equation}

According to this definition, to understand why spectral leakage occurs in the PSDs when phase discontinuities are present in the data, we have to understand how phase discontinuities affect the autocorrelation function. Sinusoids have an autocorrelation function which is a triangularly windowed sinusoid with the same frequency of the sinusoid in question. Phase discontinuities in the data make the waveform more unique, which disrupts the envelope of the autocorrelation function (this is actually the basics of phase coded waveforms, e.g. Barker codes). Specifically, it makes the autocorrelation function more of a delta shape. Using the relationship that a waveform which has little duration in the data domain has a broad Fourier response, if we take the Fourier transform of a narrow autocorrelation function, we get a broad PSD. And since phase discontinuities "tighten" the autocorrelation function, we can expect that phase discontinuities will lead to spectral leakage in the PSD estimate.

The reason you aren't noticing the change in peaks as much is probably because of the amount of data you are using. The more data you have, the more the discontinuities get averaged out, especially in Welch's method. In Welch's method, the windowing operation helps to decorrelate the data from frame to frame, to help lower the variance. See this answer for how different phase discontinuities alter the spectrum in different ways. Each frame of Welch's method will have different discontinuities and therefore different spectral leakage, which will be mitigated in the end result by the frame-to-frame decorrelation and averaging.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.