Revision: 6519 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6519&view=rev Author: ryanmay Date: 2008-12-08 21:16:04 +0000 (Mon, 08 Dec 2008)
Log Message: ----------- Add a converted MatLab example that was used to figure out the differences between MatLab and matplotlib PSD scaling. Added Paths: ----------- trunk/matplotlib/examples/pylab_examples/psd_demo3.py Added: trunk/matplotlib/examples/pylab_examples/psd_demo3.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/psd_demo3.py (rev 0) +++ trunk/matplotlib/examples/pylab_examples/psd_demo3.py 2008-12-08 21:16:04 UTC (rev 6519) @@ -0,0 +1,34 @@ +#This is a ported version of a Matlab example from the signal processing +#toolbox that showed some difference at one time between Matplotlib's and +#MatLab's scaling of the PSD. + +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.mlab as mlab + +fs = 1000 +t = np.linspace(0, 0.3, 301) +A = np.array([2, 8]).reshape(-1, 1) +f = np.array([150, 140]).reshape(-1, 1) +xn = (A * np.sin(2 * np.pi * f * t)).sum(axis=0) + 5 * np.random.randn(*t.shape) + +yticks = np.arange(-50, 30, 10) +xticks = np.arange(0,550,100) + +plt.subplot(1,2,1) +plt.psd(xn, NFFT=301, Fs=fs, window=mlab.window_none, pad_to=1024, + scale_by_freq=True) +plt.title('Periodogram PSD Estimate') +plt.yticks(yticks) +plt.xticks(xticks) +plt.grid(True) + +plt.subplot(1,2,2) +plt.psd(xn, NFFT=150, Fs=fs, window=mlab.window_none, noverlap=75, pad_to=512, + scale_by_freq=True) +plt.title('Welch Method PSD Estimate') +plt.xticks(xticks) +plt.yticks(yticks) +plt.grid(True) + +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins