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.
To create a 1D array, all zeros but for a stretch of 1.0 values - a rectangular impulse:
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
To see a plot:
import matplotlib.pyplot as mp
mp.plot(a)
mp.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With