Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92f2328

Browse files
committed
Merge pull request #4836 from ericmjl/mep12_psd_demo.py
mep12 on psd_demo.py
2 parents c202749 + f03be99 commit 92f2328

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

examples/pylab_examples/psd_demo.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
#!/usr/bin/env python
2-
# python
3-
4-
from pylab import *
1+
import matplotlib.pyplot as plt
2+
import numpy as np
53

64
dt = 0.01
7-
t = arange(0, 10, dt)
8-
nse = randn(len(t))
9-
r = exp(-t/0.05)
5+
t = np.arange(0, 10, dt)
6+
nse = np.random.randn(len(t))
7+
r = np.exp(-t/0.05)
108

11-
cnse = convolve(nse, r)*dt
9+
cnse = np.convolve(nse, r)*dt
1210
cnse = cnse[:len(t)]
13-
s = 0.1*sin(2*pi*t) + cnse
11+
s = 0.1*np.sin(2*np.pi*t) + cnse
1412

15-
subplot(211)
16-
plot(t, s)
17-
subplot(212)
18-
psd(s, 512, 1/dt)
13+
plt.subplot(211)
14+
plt.plot(t, s)
15+
plt.subplot(212)
16+
plt.psd(s, 512, 1/dt)
17+
18+
plt.show()
1919

20-
show()
2120
"""
2221
% compare with MATLAB
2322
dt = 0.01;

0 commit comments

Comments
 (0)