Creating models of continuous systems
In this example, let's look at how to create a model of a time-continuous system using the functions tf
zpk
ss
.
The ControlSystems library.jl allows you to define 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 a ratio of polynomials and , which are Laplace images of the output and input values.
In Engee, a polynomial is defined as a vector of coefficients. For example, for a polynomial: , vector of coefficients: .
We get a transfer function of the form:
num = [1, 0]; #Задаем числитель
den = [1, 2, 10]; #Задаем знаменатель
W1 = tf(num, den)
Alternatively, you can go to the Laplace domain and pass a polynomial with a variable s instead of a vector with coefficients.
s = tf('s'); #Создаем переменную Лапласа
W2 = s/(s^2 + 2*s + 10)
Setting poles and zeros
Set using the function zpk()
The model description looks like a transfer function.
The roots of the numerator are called zeros, and the denominator poles. Scalar coefficient - gain factor.
To set the model using the function zpk()
, it is necessary to transmit a vector of poles, zeros and a gain factor.
z = [0]; # Нули
p = [2,1+1im,1-1im]; # Полюса
k = -2; # коэффициент усиления
H = zpk(z,p,k)
Just as for models defined by transfer functions, you can go to the Laplace domain and transfer a polynomial with a variable s instead of a vector with coefficients.
s = zpk("s");
H = -2*s/(s - 2)/(s^2 - 2*s + 2)
A model in the state space
The state space model is a representation of differential equations in matrix form. The complete model of an object in the state space contains two equations:
where - the vector of the system state, - input vector(control signal), - output vector; - matrices.
To define a model in the state space, there is a function ss()
. To do this, the described matrices must be set as the input to the function.
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 analyzing its behavior. For example, to plot time and frequency characteristics. The functions for analyzing ACS models can be found in the [Analysis] section (https://engee.com/helpcenter/stable/julia/ControlSystems/lib/analysis.html ).