Skip to content Skip to sidebar Skip to footer

Equivalence Scipy.signal Welch To Matlab Pwelch

I have the following MATLAB code to compute the PSD of a signal: x = linspace(0, 10, 100001); dt = x(2) - x(1); Fs = 1 / dt; a1 = 1; f1 = 500; a2 = 10; f2 = 2000; y = a1 * sin(2*pi

Solution 1:

The problem is solved when using detrend=False as stated in the GitHub issue https://github.com/scipy/scipy/issues/8045#issuecomment-337319294

Solution 2:

Your parameters seem correct and I can reproduce your result in Python.

An explanation for the difference is possibly the different implementation of the Welch' method in MATLAB and SciPy. Looking at the graph and that the behavior manifests only close to zero I find this likely.

You could try to play with input values (window length, sample frequency, FFT length) a little bit and see if the problem persists. If not you may have found an edge case (perhaps do to numerical errors) in the function and there is nothing you can do about it apart from digging into the implementation details which is not possible in MATLAB's case.

Post a Comment for "Equivalence Scipy.signal Welch To Matlab Pwelch"