Engee documentation
Notebook

Creating discrete-time models

This example shows how to create linear models with discrete time.

Definition of discrete-time models

The ControlSystems library.jl allows you to create both continuous and discrete systems. The syntax for creating discrete-time models is similar to that used for continuous systems, but the sampling step (the sampling interval in seconds) must be passed in the input data to the function.

For example, to set the transfer function of a discrete system:

With a sampling period .

In [ ]:
Pkg.add(["ControlSystems"])
In [ ]:
using ControlSystems

num = [1, -1];
den = [1, -1.85, 0.9];
H = tf(num,den,0.1)
Out[0]:
TransferFunction{Discrete{Float64}, ControlSystemsBase.SisoRational{Float64}}
     1.0z - 1.0
--------------------
1.0z^2 - 1.85z + 0.9

Sample Time: 0.1 (seconds)
Discrete-time transfer function model

Similarly, you can define a model of a discrete system in the state space.:

With a sampling period .

In [ ]:
sys = ss(.5,1,.2,0,0.1)
Out[0]:
StateSpace{Discrete{Float64}, Float64}
A = 
 0.5
B = 
 1.0
C = 
 0.2
D = 
 0.0

Sample Time: 0.1 (seconds)
Discrete-time state-space model

Recognition of discrete-time systems

There are several ways to determine whether a linear model is discrete. For example, sys.Ts or H.Ts a non-zero value is returned if the model is discrete.

In [ ]:
H.Ts
Out[0]:
0.1

It can also be determined by the graph of the transition function. The system's response to a single step-by-step effect will have the form of a "ladder".

In [ ]:
using Plots

plot(step(H,8))
Out[0]:

Thus, it is possible to obtain a model of a discrete system. For more information about creating linear systems, see Building Systems.