Accelerating the pace of engineering and science

# genss

Generalized state-space model

## Description

Generalized state-space (genss) models are state-space models that include tunable parameters or components. genss models arise when you combine numeric LTI models with models containing tunable components (control design blocks). For more information about numeric LTI models and control design blocks, see Models with Tunable Coefficients.

You can use generalized state-space models to represent control systems having a mixture of fixed and tunable components. Use generalized state-space models for control design tasks such as parameter studies and parameter tuning with hinfstruct (requires Robust Control Toolbox™).

## Construction

To construct a genss model:

• Use series, parallel, lft, or connect, or the arithmetic operators +, -, *, /, \, and ^, to combine numeric LTI models with control design blocks.

• Use tf or ss with one or more input arguments that is a generalized matrix (genmat) instead of a numeric array

• Convert any numeric LTI model, control design block, or slTuner interface (requires Simulink® Control Design™), for example, sys, to genss form using:

`gensys = genss(sys)`

When sys is an slTuner interface, gensys contains all the tunable blocks and analysis points specified in this interface. To compute a tunable model of a particular I/O transfer function, call getIOTransfer(gensys,in,out). Here, in and out are the analysis points of interest. (Use getPoints(sys) to get the full list of analysis points.) Similarly, to compute a tunable model of a particular open-loop transfer function, use getLoopTransfer(gensys,loc). Here, loc is the analysis point of interest.

## Properties

 Blocks Structure containing the control design blocks included in the generalized LTI model or generalized matrix. The field names of Blocks are the Name property of each control design block. You can change some attributes of these control design blocks using dot notation. For example, if the generalized LTI model or generalized matrix M contains a realp tunable parameter a, you can change the current value of a using:`M.Blocks.a.Value = -1;` InternalDelay Vector storing internal delays. Internal delays arise, for example, when closing feedback loops on systems with delays, or when connecting delayed systems in series or parallel. For more information about internal delays, see Closing Feedback Loops with Time Delays in the Control System Toolbox™ User's Guide. For continuous-time models, internal delays are expressed in the time unit specified by the TimeUnit property of the model. For discrete-time models, internal delays are expressed as integer multiples of the sampling period Ts. For example, InternalDelay = 3 means a delay of three sampling periods. You can modify the values of internal delays. However, the number of entries in sys.InternalDelay cannot change, because it is a structural property of the model. InputDelay Input delay for each input channel, specified as a scalar value or numeric vector. For continuous-time systems, specify input delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify input delays in integer multiples of the sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods. For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each entry of this vector is a numerical value that represents the input delay for the corresponding input channel. You can also set InputDelay to a scalar value to apply the same delay to all channels. Default: 0 OutputDelay Output delays. OutputDelay is a numeric vector specifying a time delay for each output channel. For continuous-time systems, specify output delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify output delays in integer multiples of the sampling period Ts. For example, OutputDelay = 3 means a delay of three sampling periods. For a system with Ny outputs, set OutputDelay to an Ny-by-1 vector, where each entry is a numerical value representing the output delay for the corresponding output channel. You can also set OutputDelay to a scalar value to apply the same delay to all channels. Default: 0 for all output channels Ts Sampling time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period. This value is expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sampling time, set Ts = -1. Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sampling time of a discrete-time system. Default: 0 (continuous time) TimeUnit String representing the unit of the time variable. This property specifies the units for the time variable, the sampling time Ts, and any time delays in the model. Use any of the following values: 'nanoseconds''microseconds''milliseconds''seconds' 'minutes''hours''days''weeks''months''years' Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior. Default: 'seconds' InputName Input channel names. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings. Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter: `sys.InputName = 'controls';` The input names automatically expand to {'controls(1)';'controls(2)'}. You can use the shorthand notation u to refer to the InputName property. For example, sys.u is equivalent to sys.InputName. Input channel names have several uses, including: Identifying channels on model display and plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: Empty string '' for all input channels InputUnit Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior. Default: Empty string '' for all input channels InputGroup Input channel groups. The InputGroup property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure. In this structure, field names are the group names, and field values are the input channels belonging to each group. For example: ```sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5];``` creates input groups named controls and noise that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the controls inputs to all outputs using: `sys(:,'controls')` Default: Struct with no fields OutputName Output channel names. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings. Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter: `sys.OutputName = 'measurements';` The output names to automatically expand to {'measurements(1)';'measurements(2)'}. You can use the shorthand notation y to refer to the OutputName property. For example, sys.y is equivalent to sys.OutputName. Output channel names have several uses, including: Identifying channels on model display and plotsExtracting subsystems of MIMO systemsSpecifying connection points when interconnecting models Default: Empty string '' for all input channels OutputUnit Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior. Default: Empty string '' for all input channels OutputGroup Output channel groups. The OutputGroup property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure. In this structure, field names are the group names, and field values are the output channels belonging to each group. For example: ```sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5];``` creates output groups named temperature and measurement that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the measurement outputs using: `sys('measurement',:)` Default: Struct with no fields Name System name. Set Name to a string to label the system. Default: '' Notes Any text that you want to associate with the system. Set Notes to a string or a cell array of strings. Default: {} UserData Any type of data you wish to associate with system. Set UserData to any MATLAB® data type. Default: [] SamplingGrid Sampling grid for model arrays, specified as a data structure. For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables. Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array. For example, suppose you create a 11-by-1 array of linear models, sysarr, by taking snapshots of a linear time-varying system at times t = 0:10. The following code stores the time samples with the linear models. ` sysarr.SamplingGrid = struct('time',0:10)` Similarly, suppose you create a 6-by-9 model array, M, by independently sampling two variables, zeta and w. The following code attaches the (zeta,w) values to M. ```[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w)``` When you display M, each entry in the array includes the corresponding zeta and w values. `M` ```M(:,:,1,1) [zeta=0.3, w=5] = 25 -------------- s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25 ---------------- s^2 + 3.5 s + 25 ...``` Default: []

## Examples

### Tunable Low-Pass Filter

This example shows how to create the low-pass filter F = a/(s + a) with one tunable parameter a.

You cannot use ltiblock.tf to represent F, because the numerator and denominator coefficients of an ltiblock.tf block are independent. Instead, construct F using the tunable real parameter object realp.

1. Create a tunable real parameter.

```a = realp('a',10);
```

The realp object a is a tunable parameter with initial value 10.

2. Use tf to create the tunable filter F:

`F = tf(a,[1 a]);`

F is a genss object which has the tunable parameter a in its Blocks property. You can connect F with other tunable or numeric models to create more complex models of control systems. For an example, see Control System with Tunable Components.

### State-Space Model With Both Fixed and Tunable Parameters

This example shows how to create a state-space (genss) model having both fixed and tunable parameters.

Create a state-space model having the following state-space matrices:

$A=\left[\begin{array}{cc}1& a+b\\ 0& ab\end{array}\right],\text{ }B=\left[\begin{array}{c}-3.0\\ 1.5\end{array}\right],\text{ }C=\left[\begin{array}{cc}0.3& 0\end{array}\right],\text{ }D=0,$

where a and b are tunable parameters, whose initial values are –1 and 3, respectively.

1. Create the tunable parameters using realp.

``` a = realp('a',-1);
b = realp('b',3);```
2. Define a generalized matrix using algebraic expressions of a and b.

`A = [1 a+b;0 a*b]`

A is a generalized matrix whose Blocks property contains a and b. The initial value of A is M = [1 2;0 -3], from the initial values of a and b.

3. Create the fixed-value state-space matrices.

```B = [-3.0;1.5];
C = [0.3 0];
D = 0;```
4. Use ss to create the state-space model.

`sys = ss(A,B,C,D)`

sys is a generalized LTI model (genss) with tunable parameters a and b.

### Control System With Both Numeric and Tunable Components

This example shows how to create a tunable model of the control system in the following illustration.

The plant response G(s) = 1/(s + 1)2. The model of sensor dynamics is S(s) = 5/(s + 4). The controller C is a tunable PID controller, and the prefilter F = a/(s + a) is a low-pass filter with one tunable parameter, a.

Create models representing the plant and sensor dynamics.

Because the plant and sensor dynamics are fixed, represent them using numeric LTI models zpk and tf.

```G = zpk([],[-1,-1],1);
S = tf(5,[1 4]);
```

Create a tunable representation of the controller C.

`C = ltiblock.pid('C','PID');`
```C =

Parametric continuous-time PID controller "C" with formula:

1            s
Kp + Ki * --- + Kd * --------
s          Tf*s+1

and tunable parameters Kp, Ki, Kd, Tf.

Type "pid(C)" to see the current value and "get(C)" to see all properties.```

C is a ltiblock.pid object, which is a Control Design Block with a predefined proportional-integral-derivative (PID) structure.

Create a model of the filter F = a/(s + a) with one tunable parameter.

```a = realp('a',10);
F = tf(a,[1 a]);```

a is a realp (real tunable parameter) object with initial value 10. Using a as a coefficient in tf creates the tunable genss model object F.

Connect the models together to construct a model of the closed-loop response from r to y.

`T = feedback(G*C,S)*F`

T is a genss model object. In contrast to an aggregate model formed by connecting only Numeric LTI models, T keeps track of the tunable elements of the control system. The tunable elements are stored in the Blocks property of the genss model object.

Display the tunable elements of T.

`T.Blocks`
```ans =

C: [1x1 ltiblock.pid]
a: [1x1 realp]
```

If you have Robust Control Toolbox software, you can use tuning commands such as systune to tune the free parameters of T to meet design requirements you specify.

expand all

### Tips

• You can manipulate genss models as ordinary ss models. Analysis commands such as bode and step evaluate the model by replacing each tunable parameter with its current value.