3

I want to generate a rectangular impulse with python. I believe it can be done with numpy or scipy. But I cannot get it from API. After I generate the rectangular impulse, i will plot it with matplotlib.

4

1 回答 1

6

要创建一维数组,除一段 1.0 值外全为零 - 矩形脉冲:

import numpy as np
a = np.zeros( (1000,) )   # whatever size. initializes to zeros
a[150:180] = 1.0          # index range sets location, width of impulse

查看情节:

import matplotlib.pyplot as mp
mp.plot(a)
mp.show()
于 2013-10-06T03:37:38.833 回答