matplotlib

Previous topic

pylab_examples example code: print_stdout.py

Next topic

pylab_examples example code: psd_demo2.py

This Page

pylab_examples example code: psd_demo.pyΒΆ

(Source code, png)

../../_images/psd_demo1.png
#!/usr/bin/env python
# python

from pylab import *

dt = 0.01
t = arange(0, 10, dt)
nse = randn(len(t))
r = exp(-t/0.05)

cnse = convolve(nse, r)*dt
cnse = cnse[:len(t)]
s = 0.1*sin(2*pi*t) + cnse

subplot(211)
plot(t, s)
subplot(212)
psd(s, 512, 1/dt)

show()
"""
% compare with MATLAB
dt = 0.01;
t = [0:dt:10];
nse = randn(size(t));
r = exp(-t/0.05);
cnse = conv(nse, r)*dt;
cnse = cnse(1:length(t));
s = 0.1*sin(2*pi*t) + cnse;

subplot(211)
plot(t,s)
subplot(212)
psd(s, 512, 1/dt)

"""

Keywords: python, matplotlib, pylab, example, codex (see Search examples)