Code: Select all
A = np.random.randint(1, 6) # random amplitude (from 1 to 5)
tilda = 0.5 # pulse duration
SR = 1000 # sampling rate
t = np.linspace(0, 3, SR) # time range from 0 to 2 seconds
n_pulses = 3 # number of pulses
t_i = 0.5 # interval between pulses
pulse1_start = 0.25 # the beginning of the first pulse
rect_pulses = np.zeros_like(t)
for i in range(n_pulses):
pulse_start = pulse1_start + i * (tilda + t_i)
pulse_end = pulse_start + tilda
rect_pulses = np.where((t >= pulse_start) & (t