Python Program to Plot the Function x(t) with Unit Step Function
import numpy as np import matplotlib.pyplot as plt
Define the unit step function
def u(t): return np.where(t < 0, 0, 1)
Define the function x(t)
def x(t): return 0.5*(np.exp(-2t) - np.exp(-4t))u(t) - 0.5(np.exp(-2t+6) - np.exp(-4t+12))*u(t-3)
Generate the time vector
t = np.linspace(0, 10, 1000)
Generate the function values
y = x(t)
Plot the function
plt.plot(t, y, '-k', linewidth=2)
Add title and axis labels
plt.title('Plot of x(t)') plt.xlabel('t') plt.ylabel('x(t)')
Add grid lines
plt.grid(True)
Show the plot
plt.show()
原文地址: https://www.cveoy.top/t/topic/f2yY 著作权归作者所有。请勿转载和采集!