Building from scratch


The models can be built from a plist constructor describing each field. It is possible to give incomplete information on the model and let the constructor auto-complete some fields.

It is still rather lengthy to build a ssm object, and it is advisable to write built-in models to limit the time spent on modeling.

Incomplete description without parameters (params field)

The most retrained set of inputs is

sys = ssm(plist('amats', amats, 'bmats', bmats, 'cmats', cmats, 'dmats', dmats, 'timestep', timestep, 'name', name, 'statenames', statenames, 'inputnames', inputnames, 'outputnames', outputnames)))

Example:

name = 'sys';
statenames = {'ss1' 'ss2' 'ss3'};
inputnames = {'input1' 'input2' 'input3'};
outputnames = {'output1' 'output2' 'output3'};
timestep = 0;
amats = cell(3, 3);
bmats = cell(3, 3);
cmats = cell(3, 3);
dmats = cell(3, 3);
amats{1, 1} = -(sym('OMEGA'));
amats{2, 2} = -2;
amats{3, 3} = [0 1; -0.05 -0.01];
amats{3, 1} = [-1; -3];
bmats{1, 1} = 1;
bmats{2, 2} = 2;
bmats{3, 3} = 3*eye(2);
cmats{1, 1} = 1;
cmats{2, 2} = 1;
cmats{3, 3} = eye(2);
dmats{1, 3} = [6 6];
dmats{2, 1} = 6;
dmats{3, 2} = [6; 6];
sys = ssm(plist(...
'amats', amats, 'bmats', bmats, 'cmats', cmats, 'dmats', dmats, ...
'timestep', timestep, ...
'name', name, 'statenames', statenames, 'inputnames', inputnames, 'outputnames', outputnames))
------ ssm/1 -------
      amats: {  [1 x1 ]    []      []       
                 []    [-2]   []            
                [2 x1 ]    []     [2 x2 ]  }  [3x3]
      bmats: { [1]   []      []           
                 []    [2]   []           
                 []      []     [2 x2 ]  }  [3x3]
      cmats: { [1]   []      []           
                 []    [1]   []           
                 []      []     [2 x2 ]  }  [3x3]
      dmats: { [0]   []     [1 x2 ]       
               [6] [0]   []               
                 []     [2 x1 ]    []    }  [3x3]
   timestep: 0
     inputs:  [1x3 ssmblock]
         1 : INPUT1 | variable_1 []
         2 : INPUT2 | variable_1 []
         3 : INPUT3 | variable_1 [], variable_2 []
     states:  [1x3 ssmblock]
         1 : SS1 | variable_1 []
         2 : SS2 | variable_1 []
         3 : SS3 | variable_1 [], variable_2 []
    outputs:  [1x3 ssmblock]
         1 : OUTPUT1 | variable_1 []
         2 : OUTPUT2 | variable_1 []
         3 : OUTPUT3 | variable_1 [], variable_2 []
  numparams: (empty-plist)
     params: (empty-plist)
    Ninputs: 3
 inputsizes: [1 1 2]
   Noutputs: 3
outputsizes: [1 1 2]
    Nstates: 3
 statesizes: [1 1 2]
 Nnumparams: 0
    Nparams: 0
isnumerical: false
       hist: ssm.hist 
   procinfo: []
   plotinfo: []
       name: sys
description: 
       UUID: ff67a657-e5fb-4f80-8a40-02725ee1801c
--------------------

Then the field “params” must be set by the user using the syntax “sys.setParams(<parameter plist>)”. Otherwise the toolbox will simply assume there are no parameters in the system and the matrices should be exclusively numerical in this case..

The content of “params” is a plist with parameters whose:

sys.setParams(plist({'OMEGA', 'system frequency'}, 2))
------ ssm/1 -------
      amats: {  [1 x1 ]    []      []       
                 []    [-2]   []            
                [2 x1 ]    []     [2 x2 ]  }  [3x3]
      bmats: { [1]   []      []           
                 []    [2]   []           
                 []      []     [2 x2 ]  }  [3x3]
      cmats: { [1]   []      []           
                 []    [1]   []           
                 []      []     [2 x2 ]  }  [3x3]
      dmats: { [0]   []     [1 x2 ]       
               [6] [0]   []               
                 []     [2 x1 ]    []    }  [3x3]
   timestep: 0
     inputs:  [1x3 ssmblock]
         1 : INPUT1 | variable_1 []
         2 : INPUT2 | variable_1 []
         3 : INPUT3 | variable_1 [], variable_2 []
     states:  [1x3 ssmblock]
         1 : SS1 | variable_1 []
         2 : SS2 | variable_1 []
         3 : SS3 | variable_1 [], variable_2 []
    outputs:  [1x3 ssmblock]
         1 : OUTPUT1 | variable_1 []
         2 : OUTPUT2 | variable_1 []
         3 : OUTPUT3 | variable_1 [], variable_2 []
  numparams: (empty-plist)
     params: (OMEGA=2)
    Ninputs: 3
 inputsizes: [1 1 2]
   Noutputs: 3
outputsizes: [1 1 2]
    Nstates: 3
 statesizes: [1 1 2]
 Nnumparams: 0
    Nparams: 1
isnumerical: false
       hist: ssm.hist 
   procinfo: []
   plotinfo: []
       name: sys
description: 
       UUID: 15da354b-aa4f-44e8-bb73-30316359b20b
--------------------

The method “setParams” should not be confused with “setParameters” which only allows to modify the property VALUE in the “params” field.

Input blocks and input variables will be automatically named after their index number in this case, and the description field will be empty.

Complete description

A complete description (with parameters) example is:

name = 'sys';
statenames = {'ss1' 'ss2' 'ss3'};
inputnames = {'input1' 'input2' 'input3'};
outputnames = {'output1' 'output2' 'output3'};
timestep = 0;
amats = cell(3, 3);
bmats = cell(3, 3);
cmats = cell(3, 3);
dmats = cell(3, 3);
amats{1, 1} = -(sym('OMEGA'));
amats{2, 2} = -2;
amats{3, 3} = [0 1; -0.05 -0.01];
amats{3, 1} = [-1; -3];
bmats{1, 1} = 1;
bmats{2, 2} = 2;
bmats{3, 3} = 3*eye(2);
cmats{1, 1} = 1;
cmats{2, 2} = 1;
cmats{3, 3} = eye(2);
dmats{1, 3} = [6 6];
dmats{2, 1} = 6;
dmats{3, 2} = [6; 6];
params = plist({'OMEGA', 'system frequency'}, 2);
sys = ssm(plist(...
'amats', amats, 'bmats', bmats, 'cmats', cmats, 'dmats', dmats, ...
'timestep', timestep, ...
'name', name, 'statenames', statenames, 'inputnames', inputnames, 'outputnames', outputnames, ...
'params', params))
------ ssm/1 -------
      amats: {  [1 x1 ]    []      []       
                 []    [-2]   []            
                [2 x1 ]    []     [2 x2 ]  }  [3x3]
      bmats: { [1]   []      []           
                 []    [2]   []           
                 []      []     [2 x2 ]  }  [3x3]
      cmats: { [1]   []      []           
                 []    [1]   []           
                 []      []     [2 x2 ]  }  [3x3]
      dmats: { [0]   []     [1 x2 ]       
               [6] [0]   []               
                 []     [2 x1 ]    []    }  [3x3]
   timestep: 0
     inputs:  [1x3 ssmblock]
         1 : INPUT1 | variable_1 []
         2 : INPUT2 | variable_1 []
         3 : INPUT3 | variable_1 [], variable_2 []
     states:  [1x3 ssmblock]
         1 : SS1 | variable_1 []
         2 : SS2 | variable_1 []
         3 : SS3 | variable_1 [], variable_2 []
    outputs:  [1x3 ssmblock]
         1 : OUTPUT1 | variable_1 []
         2 : OUTPUT2 | variable_1 []
         3 : OUTPUT3 | variable_1 [], variable_2 []
  numparams: (empty-plist)
     params: (OMEGA=2)
    Ninputs: 3
 inputsizes: [1 1 2]
   Noutputs: 3
outputsizes: [1 1 2]
    Nstates: 3
 statesizes: [1 1 2]
 Nnumparams: 0
    Nparams: 1
isnumerical: false
       hist: ssm.hist 
   procinfo: []
   plotinfo: []
       name: sys
description: 
       UUID: 439fa9e2-b24c-4306-99b0-db7a1b868857
--------------------



©LTP Team