#### 30.2.5 Data structure access functions

— Function File: syschnames (sys, opt, list, names)

> Superseded by `syssetsignals`.

— Function File: syschtsam (sys, tsam)

> This function changes the sampling time (tsam) of the system. Exits with an error if sys is purely continuous time.

— Function File: [n, nz, m, p, yd] = sysdimensions (sys, opt)

> return the number of states, inputs, and/or outputs in the system sys.

> Inputs

> sys
>   system data structure
> opt
>   String indicating which dimensions are desired. Values:
>   `"all"`
>     (default) return all parameters as specified under Outputs below.
>   `"cst"`
>     return n= number of continuous states
>   `"dst"`
>     return n= number of discrete states
>   `"in"`
>     return n= number of inputs
>   `"out"`
>     return n= number of outputs

> Outputs

> n
>   number of continuous states (or individual requested dimension as specified by opt).
> nz
>   number of discrete states
> m
>   number of system inputs
> p
>   number of system outputs
> yd
>   binary vector; yd(ii) is nonzero if output ii is discrete. yd(ii) = 0 if output ii is continuous

> See also: sysgetsignals, sysgettsam.

— Function File: [stname, inname, outname, yd] = sysgetsignals (sys)
— Function File: siglist = sysgetsignals (sys, sigid)
— Function File: signame = sysgetsignals (sys, sigid, signum, strflg)

> Get signal names from a system

> Inputs

> sys
>   system data structure for the state space system
> sigid
>   signal id. String. Must be one of
>   `"in"`
>     input signals
>   `"out"`
>     output signals
>   `"st"`
>     stage signals
>   `"yd"`
>     value of logical vector yd
> signum
>   index(indices) or name(s) or signals; see `sysidx`
> strflg
>   flag to return a string instead of a cell array; Values:
>   `0`
>     (default) return a cell array (even if signum specifies an individual signal)
>   `1`
>     return a string. Exits with an error if signum does not specify an individual signal.

> Outputs

> •If sigid is not specified:
>   stname
>   inname
>   outname
>     signal names (cell array of strings); names of states, inputs, and outputs, respectively.
>   yd
>     binary vector; yd(ii) is nonzero if output ii is discrete.
> •If sigid is specified but signum is not specified:
>   `sigid="in"`
>     siglist is set to the cell array of input names.
>   `sigid="out"`
>     siglist is set to the cell array of output names.
>   `sigid="st"`
>     siglist is set to the cell array of state names.

>     stage signals

>   `sigid="yd"`
>     siglist is set to logical vector indicating discrete outputs; siglist(ii) = 0 indicates that output ii is continuous (unsampled), otherwise it is discrete.
> •If the first three input arguments are specified:
>   signame is a cell array of the specified signal names (sigid is `"in"`, `"out"`, or `"st"`), or else the logical flag indicating whether output(s) signum is(are) discrete (sigval=1) or continuous (sigval=0).

> Examples (From `sysrepdemo`)

>               octave> sys=ss(rand(4),rand(4,2),rand(3,4));
>               octave># get all signal names
>               octave> [Ast,Ain,Aout,Ayd] = sysgetsignals(sys)
>               Ast =
>               (
>                 [1] = x_1
>                 [2] = x_2
>                 [3] = x_3
>                 [4] = x_4
>               )
>               Ain =
>               (
>                 [1] = u_1
>                 [2] = u_2
>               )
>               Aout =
>               (
>                 [1] = y_1
>                 [2] = y_2
>                 [3] = y_3
>               )
>               Ayd =

>                 0  0  0
>               octave> # get only input signal names:
>               octave> Ain = sysgetsignals(sys,"in")
>               Ain =
>               (
>                 [1] = u_1
>                 [2] = u_2
>               )
>               octave> # get name of output 2 (in cell array):
>               octave> Aout = sysgetsignals(sys,"out",2)
>               Aout =
>               (
>                 [1] = y_2
>               )
>               octave> # get name of output 2 (as string):
>               octave> Aout = sysgetsignals(sys,"out",2,1)
>               Aout = y_2

— Function File: sysgettype (sys)

> return the initial system type of the system

> Input

> sys
>   System data structure.

> Output

> systype
>   String indicating how the structure was initially constructed. Values: `"ss"`, `"zp"`, or `"tf"`.

> FIR initialized systems return `systype="tf"`.

— Function File: syssetsignals (sys, opt, names, sig_idx)

> change the names of selected inputs, outputs and states.

> Inputs

> sys
>   System data structure.
> opt
>   Change default name (output).
>   `"out"`
>     Change selected output names.
>   `"in"`
>     Change selected input names.
>   `"st"`
>     Change selected state names.
>   `"yd"`
>     Change selected outputs from discrete to continuous or from continuous to discrete.
> names
>   `opt = "out", "in", "st"`
>     string or string array containing desired signal names or values.
>   `opt = "yd"`
>     To desired output continuous/discrete flag. Set name to 0 for continuous, or 1 for discrete.
> sig_idx
>   indices or names of outputs, yd, inputs, or states whose respective names/values should be changed.

>   Default: replace entire cell array of names/entire yd vector.

> Outputs

> retsys
>   sys with appropriate signal names changed (or yd values, where appropriate).

> Example

>               octave:1> sys=ss ([1 2; 3 4],[5;6],[7 8]);
>               octave:2> sys = syssetsignals (sys, "st",
>               >                              str2mat("Posx","Velx"));
>               octave:3> sysout(sys)
>               Input(s)
>                       1: u_1
>               Output(s):
>                       1: y_1
>               state-space form:
>               2 continuous states, 0 discrete states
>               State(s):
>                       1: Posx
>                       2: Velx
>               A matrix: 2 x 2
>                 1  2
>                 3  4
>               B matrix: 2 x 1
>                 5
>                 6
>               C matrix: 1 x 2
>                 7  8
>               D matrix: 1 x 1
>               0

— Function File: sysupdate (sys, opt)

> Update the internal representation of a system.

> Inputs

> sys:
>   system data structure
> opt
>   string:
>   `"tf"`
>     update transfer function form
>   `"zp"`
>     update zero-pole form
>   `"ss"`
>     update state space form
>   `"all"`
>     all of the above

> Outputs

> retsys
>   Contains union of data in sys and requested data. If requested data in sys is already up to date then retsys=sys.

> Conversion to `tf` or `zp` exits with an error if the system is mixed continuous/digital.

> See also: tf, ss, zp, sysout, sys2ss, sys2tf, sys2zp.

— Function File: [systype, nout, nin, ncstates, ndstates] = minfo (inmat)

> Determines the type of system matrix. inmat can be a varying, a system, a constant, and an empty matrix.

> Outputs

> systype
>   Can be one of: varying, system, constant, and empty.
> nout
>   The number of outputs of the system.
> nin
>   The number of inputs of the system.
> ncstates
>   The number of continuous states of the system.
> ndstates
>   The number of discrete states of the system.

— Function File: sysgettsam (sys)

> Return the sampling time of the system sys.