How to implement Matlab welch in python with the same result? I want to implement Matlab pwelch function in python.
The Matlab code is shown blew:

[PSD,f] = pwelch(data,length(data),[],[],2000);


which data is a row vector of double type with size (1 * 1547600)

My python code is:

f, Pxx_den = signal.welch(data, fs=2000, window=signal.hanning(len(data)), return_onesided=True, detrend=False)


The output of python code doesn't equal to the output of the Matlab code and I don't know how to set python welch arguments to reach Matlab output results.

Thanks for your attention.
As written in Matlab pwelch document, by using an integer for window, a Hamming window of length window(integer) will be used. Also the nfft in python should set to the next power of two greater than length of window.

freqs, PSD = signal.welch(data, fs=2000, window=signal.windows.hamming(len(window)), nfft=num_fft, scaling='density', return_onesided=True, detrend=False)