''' Compute the velocity curve of a force-time signal in Python ''' import numpy as np import matplotlib.pyplot as plt # Define the force-time signal t = np.linspace(0, 10, 1000) # Time vector f = np.sin(t) + np.random.normal(scale=0.1, size=t.shape) # Simulated force signal with added noise # Compute the velocity curve by numerical integration of the force signal v = np.cumsum(f) # Cumulative sum of the force signal v -= np.mean(v) # Remove any DC offset dt = t[1] - t[0] # Time step v /= dt # Divide by time step to get velocity # Plot the force and velocity signals fig, ax = plt.subplots() ax.plot(t, f, label='Force') ax.plot(t, v, label='Velocity') ax.legend() ax.set_xlabel('Time') ax.set_ylabel('Force / Velocity') plt.show()