I have seen some questions asked about step functions in matplotlib but this one is different. Here is my function:
def JerkFunction(listOfJerk):
'''Return the plot of a sequence of jerk'''
#initialization of the jerk
x = np.linspace(0,5,4)
y = listOfJerk #step signal
plt.axis([0,5,-2,2])
plt.step(x,y,'y') #step display
plt.xlabel('Time (s)')
plt.ylabel('Jerk (m/s^3)')
plt.title('Jerk produced by the engine')
return plt.show()
I would like to have the curve obtained when I put JerkFunction([1,1,-1,1])
but by entering: [1,-1,1,-1]
, indeed, at the beginning, in a real case, the jerk value is 0 and at t=0
, it becomes jerk=+1
, then at t=
1 it is Jerk=-1
etc.