115회 2번 문제 풀이¶

In [1]:
import sympy
import control as ct
import numpy as np
In [2]:
num = [4, 6, 10]
den = [1, 4, 6, 10]
system = ct.tf(num,den)
system
Out[2]:
$$\frac{4 s^2 + 6 s + 10}{s^3 + 4 s^2 + 6 s + 10}$$
In [3]:
#u(t)를 입력할 경우.
num_us = [1]
den_us = [1, 0]
Us = ct.tf(num_us, den_us)
Us
Out[3]:
$$\frac{1}{s}$$
In [4]:
system_GU = system * Us
system_GU
Out[4]:
$$\frac{4 s^2 + 6 s + 10}{s^4 + 4 s^3 + 6 s^2 + 10 s}$$
In [5]:
#u(t)를 입력으로 놓을 경우, error
system_error = ct.tf([1], [1, 4, 6, 10, 0])
system_error
Out[5]:
$$\frac{1}{s^4 + 4 s^3 + 6 s^2 + 10 s}$$
In [6]:
ct.step_info(system)
Out[6]:
{'RiseTime': 0.31135134292033206,
 'SettlingTime': 6.849729544247305,
 'SettlingMin': 0.8240077331892378,
 'SettlingMax': 1.3315308280991212,
 'Overshoot': 33.153082809912114,
 'Undershoot': 0,
 'Peak': 1.3315308280991212,
 'PeakTime': 0.9340540287609962,
 'SteadyStateValue': 1.0}
In [7]:
import matplotlib.pyplot as plt
# Time vector
time, response = ct.step_response(system)
# Plot the step response
plt.plot(time, response)
plt.title('Step Response')
plt.xlabel('Time (seconds)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.show()