I am trying to implement the following simple condition with numpy arrays, but the output is wrong.
dt = 1.0
t = np.arange(0.0, 5.0, dt)
x = np.empty_like(t)
if np.where((t >=0) & (t < 3)):
x = 2*t
else:
x=4*t
I get the output below
array([0., 2., 4., 6., 8.])
But I am expecting
array([0., 2., 4., 12., 16.])
Thanks for your help!