Why is the function defined as shown below not working? I am getting the error msg ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Thanks in advance.
import math
from math import sin, cos, exp, pi, sqrt
from matplotlib import pyplot as plt
def pulse(Amax,td,t):
if t<=td:
y = Amax*sin((pi/td)*t)
else:
y = 0
return y
t = np.linspace(0,4*pi,100)
Amax=10
td=11/1000
plt.plot(t,pulse(Amax,td,t), 'r', label='pulse A=10,td=11')