Rev | Line | |
---|
[3187] | 1 | from Numeric import arange, sin, exp, pi |
---|
| 2 | from pylab import randn, conv, plot, psd, subplot, show |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | # Create signal |
---|
| 6 | dt = 0.01 |
---|
| 7 | t = arange(0, 10, dt) # Time vector |
---|
| 8 | signal = 0.1*sin(2*pi*t) |
---|
| 9 | |
---|
| 10 | # Create noise |
---|
| 11 | noise = conv(randn(len(t)), exp(-t/0.05))*dt |
---|
| 12 | noise = noise[:len(t)] |
---|
| 13 | |
---|
| 14 | # Create noisy signal and plot |
---|
| 15 | noisy_signal = signal + noise |
---|
| 16 | |
---|
| 17 | subplot(211) |
---|
| 18 | plot(t, noisy_signal) |
---|
| 19 | subplot(212) |
---|
| 20 | psd(noisy_signal, 512, 1/dt) |
---|
| 21 | |
---|
| 22 | show() |
---|
| 23 | |
---|
Note: See
TracBrowser
for help on using the repository browser.