LTPDA Toolbox™ | contents | ![]() ![]() |
Built-in models enable to build fast predefined models to use later in simulations.
Once the parameters field “params” is set, one may want to set or modify (like in an optimizer) the parameter values. This is done by the functions “*Parameters.m”. The function setParameters takes two inputs ('setnames' and 'setvalues') which are the names of the parameters to modify and the values assigned to them.
sys.params
----------- plist 01 -----------
n params: 1
---- param 1 ----
key: OMEGA
val: 2
desc: system frequency
origin: default
-----------------
description:
--------------------------------
sys.setParameters('OMEGA', 0.002);
sys.params
----------- plist 01 -----------
n params: 1
---- param 1 ----
key: OMEGA
val: 0.002
origin: default
-----------------
description:
--------------------------------
The function subsParameters substitute numerical values to the symbolic expressions, using a list of the parameters to substitute (or its complementary). All parameters substituted are removed from the “params” field. The call <system>.subsParameters substitutes all the parameters. The field “isnumerical” is then set to true, unless a parameter in the matrices was forgotten in the params field.
sys.subsParameters; sys.params ----------- plist 01 ----------- n params: 0 description: -------------------------------- sys.numparams ----------- plist 01 ----------- n params: 1 ---- param 1 ---- key: OMEGA val: 0.002 desc: system frequency origin: default ----------------- description: --------------------------------
Les us first build a simple system constituted of four parallel 1st order systems. Please notice that we do not need to specify names for the states, the inputs, and the outputs, since they are only 1.
name = 'sys'; timestep = 0; amats = {diag([-1 -2 -3 -4])}; bmats = {diag([1 2 0 0])}; cmats = {[diag([1 0 3 0]) ; [0 0 0 0]]}; dmats = {[diag([0 0 0 0]) ; [0 0 0 0]]}; sys = ssm(plist(... 'amats', amats, 'bmats', bmats, 'cmats', cmats, 'dmats', dmats, ... 'timestep', timestep, 'name', name));
It is possible to obtain the structural realization of the system using sMinReal.
This function deletes states which are either not observable or controllable. However, there may still exist such linear combinations of states.
The process only modify the states, here the 2nd and 4rt states disappear since they are not observable, and the 3rd and 4th disappear since they are not controllable.
Then we can work on the input/outputs to simplify the model. The user must specify which block variable he want to keep, and
three syntaxes are allowed.
'ALL'
meaning all ports in all blocks are kept {<varname1>
<varname2> …} giving the name of each port to keep, in
this case one must ensure ports of different blocks have different
names. {<logical
index for block1> <double index for block2> <varnames
cellstr for block3> “ALL” “NONE”} using a
different index for each individual block. This
syntax is also used for any converter to select the inputs and
outputs in the ssm. It is important to note that this removes lines and columns in the
system's matrices, but no parameters are removed. So second order
parameters that should be remove (by setting them to a neutral value)
must be taken care of separately.
sys.sMinReal
M: running display
------ ssm/1 -------
amats: { [-1] } [1x1]
bmats: { [1 x4 ] } [1x1]
cmats: { [5 x1 ] } [1x1]
dmats: { [] } [1x1]
timestep: 0
inputs: [1x1 ssmblock]
1 : INPUT | variable_1 [], variable_2 [], variable_3 [], variable_4 []
states: [1x1 ssmblock]
1 : STATE | variable_1 []
outputs: [1x1 ssmblock]
1 : OUTPUT | variable_1 [], variable_2 [], variable_3 [], variable_4 [], variable_5 []
numparams: (empty-plist)
params: (empty-plist)
Ninputs: 1
inputsizes: 4
Noutputs: 1
outputsizes: 5
Nstates: 1
statesizes: 1
Nnumparams: 0
Nparams: 0
isnumerical: true
hist: ssm.hist
procinfo: []
plotinfo: []
name: sys
description:
UUID: 35d11cad-45a5-4f42-bace-e1d179cf00b6
--------------------
sys.simplify(plist('inputs', {[1 2]} , 'states', 'ALL' , 'outputs', { 'OUTPUT1.variable_1' 'OUTPUT1.variable_4'}))
M: running display
------ ssm/1 -------
amats: { [4 x4 ] } [1x1]
bmats: { [4 x2 ] } [1x1]
cmats: { [2 x4 ] } [1x1]
dmats: { [] } [1x1]
timestep: 0
inputs: [1x1 ssmblock]
1 : INPUT1 | variable_1 [], variable_2 []
states: [1x1 ssmblock]
1 : SS1 | variable_1 [], variable_2 [], variable_3 [], variable_4 []
outputs: [1x1 ssmblock]
1 : OUTPUT1 | variable_1 [], variable_4 []
numparams: (empty-plist)
params: (empty-plist)
Ninputs: 1
inputsizes: 2
Noutputs: 1
outputsizes: 2
Nstates: 1
statesizes: 4
Nnumparams: 0
Nparams: 0
isnumerical: true
hist: ssm.hist
procinfo: []
plotinfo: []
name: sys
description:
UUID: 75efcf24-d714-4c6d-9ec8-b069c48dff4d
--------------------
![]() |
Building from built-in models | Assembling systems | ![]() |
©LTP Team