arange ( 0 ,nfft, 1 ) for k in range (nrecs ):
Import numpy, pylab, time from math import pi The same program written in Python language, using NumPy and Matplotlib libraries would look like this: Nrecs= fix ( ( length (t )-noverlap )/nadvance ) į= ( 0:nfft/ 2- 1 )/ (nfft/ 2- 1 )* (fs/ 2 ) įigure plot (f, 10* log10 (Pxx ) ) % in dB xlabel ( 'f ' ) ylabel ( 'PSD ' ) saveas ( gcf, 'fig_PSD_matlab.png', 'png' ) % timeĬzas_=