Added piecewise snippet

This commit is contained in:
xavi 2024-03-22 18:06:25 -07:00
parent 8ebc6a36bc
commit 1a48e961bb

18
piecewise/piecewise Normal file
View File

@ -0,0 +1,18 @@
import numpy as np
import matplotlib.pyplot as plt
tot_time = 200
time1 = 30
time2 = 90
time3 = 150
depth0 = 0
depth1 = 3
depth2 = 5
depth_des = np.arange(tot_time)
depth_des = np.piecewise(depth_des, [depth_des < time1, (depth_des >= time1) & (depth_des < time2), (depth_des >= time2) & (depth_des < time3), depth_des >= time3], [depth0, depth1, depth2, depth0])
plt.plot(depth_des)