Engee documentation
Notebook

An array of models with one variable parameter

This example shows how to create a one-dimensional array of transfer functions. One parameter of the transfer function varies from model to model in the array. You can use such an array to study the effect of parameter changes on your model, for example, to analyze sensitivity.

In [ ]:
import Pkg
Pkg.add("ControlSystems")
In [ ]:
using ControlSystems
s = tf('s');

Create an array of transfer functions representing the following low-pass filter at three cutoff frequency values .

Create transfer function models representing a filter with a cutoff frequency = 3, 5 and 7.

In [ ]:
a = [3, 5, 7]

F_array = [ tf([a[i]],[1,a[i]]) for i=1:length(a) ]
Out[0]:
3-element Vector{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}}:
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  3
-----
s + 3

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  5
-----
s + 5

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  7
-----
s + 7

Continuous-time transfer function model

The inclusion method allows us to create a vector of transfer functions with a variable parameter.

Let's construct a Bode diagram for F_array.

In [ ]:
bodeplot(F_array)
Out[0]:

When you use analysis commands such as bodeplot For an array of models, the resulting graph shows the response of each model in the array. This way, you can see the range of responses resulting from parameter changes.

The models from the vector can be combined and a MIMO system can be obtained.

Converting an array of systems into a multidimensional system

You can create a diagonal multidimensional system from a vector of systems using the function append. As a result, we will have a system with three inputs and three outputs.

In [ ]:
P1 = append(F_array[1], F_array[2], F_array[3])
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
Input 1 to output 1
  3
-----
s + 3

Input 1 to output 2
0
-
1

Input 1 to output 3
0
-
1

Input 2 to output 1
0
-
1

Input 2 to output 2
  5
-----
s + 5

Input 2 to output 3
0
-
1

Input 3 to output 1
0
-
1

Input 3 to output 2
0
-
1

Input 3 to output 3
  7
-----
s + 7

Continuous-time transfer function model

Other function array2mimo allows you to create a system with one input and three outputs.

In [ ]:
P2 = array2mimo(F_array)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
Input 1 to output 1
  3
-----
s + 3

Input 1 to output 2
  5
-----
s + 5

Input 1 to output 3
  7
-----
s + 7

Continuous-time transfer function model

To return to the array of systems or get a vector from the MIMO system, you can apply the function getindex.

In [ ]:
sys_array = getindex.(Ref(P2), 1:P2.ny, (1:P2.nu)')
Out[0]:
3×1 Matrix{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}}:
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  3
-----
s + 3

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  5
-----
s + 5

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  7
-----
s + 7

Continuous-time transfer function model

Conclusion

We looked at how to create an array of models with a variable parameter.We also learned which functions allow you to switch from an array to a MIMO system and back.