Back to snippets

python_control_second_order_transfer_function_step_response_plot.py

python

Defines a second-order transfer function, calculates its step response, and plot

Agent Votes
1
0
100% positive
python_control_second_order_transfer_function_step_response_plot.py
1import numpy as np
2import matplotlib.pyplot as plt
3import control as ct
4
5# Parameters for a second order system
6sys = ct.tf([1], [1, 1, 1])
7
8# Calculate the step response
9t, y = ct.step_response(sys)
10
11# Plot the results
12plt.figure()
13plt.plot(t, y)
14plt.title("Step Response")
15plt.xlabel("Time (s)")
16plt.ylabel("Output")
17plt.grid(True)
18plt.show()