Creation of continuous systems models¶
In this example, let's see how to create a model of a time-continuous system using the functions tf
zpk
ss
.
The ControlSystems.jl library allows you to specify linear models of continuous systems in three different ways:
- Transfer functions (
tf
) - Setting poles and zeros (
zpk
) - State space (
ss
)
Pkg.add(["ControlSystems"])
#Подключение библиотеки для работы с САУ
using ControlSystems
Transfer functions¶
For SISO systems, the transfer function is the ratio of the polynomials $A(s)$ and $B(s)$, which are Laplace images of the output and input quantities.
$$ W(s)={\frac{A(s)}{B(s)}}={\frac{a_1s^n+a_2s^{n-1}+...+a_ns^{n+1}}{b_1s^m+b_2s^{m-1}+...+a_ms^{m+1}}} $$
In Engee, a polynomial is defined as a vector of coefficients. For example, for the polynomial: $s^2 + 2s + 10$, the vector of coefficients is: $[1, 2, 10]$.
We obtain the transfer function of the form:
num = [1, 0]; #Задаем числитель
den = [1, 2, 10]; #Задаем знаменатель
W1 = tf(num, den)
As another option, we can pass to the Laplace domain and instead of a vector with coefficients, we can pass a polynomial with variable s.
s = tf('s'); #Создаем переменную Лапласа
W2 = s/(s^2 + 2*s + 10)
Setting of poles and zeros¶
The model description defined with the function zpk()
looks like a transfer function.
$$
H(s) = {k\frac{(s-z_1)...(s-z_n)}{(s-p_1)...(s-p_m)}}
$$
The roots of the numerator are called zeros and the roots of the denominator are called poles. The scalar coefficient $k$ is the gain.
To specify the model through the function zpk()
, you need to pass the vector of poles, zeros and gain.
z = [0]; # Нули
p = [2,1+1im,1-1im]; # Полюса
k = -2; # коэффициент усиления
H = zpk(z,p,k)
As for models defined by transfer functions, you can also go to the Laplace domain and pass a polynomial with variable s instead of a vector with coefficients.
s = zpk("s");
H = -2*s/(s - 2)/(s^2 - 2*s + 2)
Model in state space¶
A state-space model is a representation of differential equations in matrix form. A complete state-space model of an object contains two equations:
$$\frac{dx}{dt}=Ax(t)+Bu(t)$$ $$y(t) = Cx(t)+Du(t)$$
where $x(t)$ - system state vector, $u(t)$ - input vector (control signal), $y(t)$ - output vector; $A,B,C,D$ - matrices.
To specify the model in the state space there is a function ss()
. For this purpose, the input of the function should be given the described matrices.
A = [0 1 ; -5 -2];
B = [0 ; 3];
C = [1 0];
D = 0;
H = ss(A,B,C,D)
The description of the system model allows you to start analysing its behaviour. For example, to plot time and frequency characteristics. Functions for analysing ACS models can be found in Analysis.