・ I created this page when I received a comment on the qiita page (https://qiita.com/sato235/items/f991411074c578d1640c) that I wrote last time that it would be interesting to output a waveform graph and consider it.
[1] Hiroki Minami, Ohmsha, "Introduction to Control Engineering with Python"
a) Author support page of [1], https://y373.sakura.ne.jp/minami/pyctrl b) Last self-page, https://qiita.com/sato235/items/f991411074c578d1640c c) Graphing function of matlab function of control module, http://matsulib.hatenablog.jp/entry/2013/04/27/093008
First, import the module.
import sympy
from control import matlab
import numpy as np
import matplotlib.pyplot as plt
Create transfer function
Np = [0,1]
Dp = [1,2,3]
P = matlab.tf(Np, Dp)
print(P)
Transfer function output
1
-------------
s^2 + 2 s + 3
When a step function is input to the above transfer function.
t = np.linspace(0, 3, 1000)
yout, T = matlab.step(P, t)
plt.plot(T, yout,label="test")
plt.axhline(1, color="b", linestyle="--")
plt.legend(bbox_to_anchor=(1, 0.25), loc='upper right', borderaxespad=0, fontsize=11)
When an impulse response function is input to the transfer function P.
yout, T = matlab.impulse(P, t)
plt.plot(T, yout,label="test")
plt.axhline(0, color="b", linestyle="--")
plt.xlim(0, 3)
plt.legend(bbox_to_anchor=(1, 1), loc='upper right', borderaxespad=0, fontsize=11)
-I learned that the control module has a matlab calculation function. -Similarly, there was also a drawing function of matplotlib. ・ Next, I would like to consider the results obtained by changing the input function.
Recommended Posts