Sparse first-order state-space model

Since R2020b

Description

Use `sparss` to represent sparse descriptor state-space models using matrices obtained from your finite element analysis (FEA) package. FEA involves the concept of dynamic substructuring where a mechanical system is partitioned into components that are modeled separately. These components are then coupled using rigid or semi-rigid physical interfaces that express consistency of displacements and equilibrium of internal forces. The resultant matrices from this type of modeling are quite large with a sparse pattern. Hence, using `sparss` is an efficient way to represent such large sparse state-space models in MATLAB® to perform linear analysis. You can also use `sparss` to convert a second-order `mechss` model object to a `sparss` object.

You can use `sparss` model objects to represent SISO or MIMO state-space models in continuous time or discrete time. In continuous time, a first-order sparse state-space model is represented in the following form:

Here, `x`, `u` and `y` represent the states, inputs and outputs respectively, while `A`, `B`, `C`, `D` and `E` are the state-space matrices. The `sparss` object represents a state-space model in MATLAB storing sparse matrices `A`, `B`, `C`, `D` and `E` along with other information such as sample time, names and delays specific to the inputs and outputs.

You can use a `sparss` object to:

• Perform time-domain and frequency-domain response analysis.

• Specify signal-based connections with other LTI models.

• Transform models between continuous-time and discrete-time representations.

Creation

Syntax

``sys = sparss(A,B,C,D,E)``
``sys = sparss(A,B,C,D,E,ts)``
``sys = sparss(D)``
``sys = sparss(___,Name,Value)``
``sys = sparss(ltiSys)``

Description

example

````sys = sparss(A,B,C,D,E)` creates a continuous-time first-order sparse state-space model object of the following form: For instance, consider a plant with `Nx` states, `Ny` outputs, and `Nu` inputs. The first-order state-space matrices are:`A` is the sparse state matrix with `Nx`-by-`Nx` real- or complex-values.`B` is the sparse input-to-state matrix with `Nx`-by-`Nu` real- or complex-values. is the sparse state-to-output matrix with `Ny`-by-`Nx` real- or complex-values.`D` is the sparse gain or input-to-output matrix with `Ny`-by-`Nu` real- or complex-values.`E` is the sparse mass matrix with the same size as matrix `A`. When `E` is omitted, `sparss` populates `E` with an identity matrix.```

example

````sys = sparss(A,B,C,D,E,ts)` creates a discrete-time sparse state-space model with sample time `ts` with the form: To leave the sample time unspecified, set `ts` to `-1`. When `E` is an identity matrix, you can set `E` as `[]` or omit `E` as long as `A` is not a scalar.```

example

````sys = sparss(D)` creates a sparse state-space model that represents the static gain, `D`. The output state-space model is equivalent to `sparss([],[],[],D,[])`.```

example

````sys = sparss(___,Name,Value)` sets properties of the first-order sparse state-space model using one or more name-value pair arguments. Use this syntax with any of the previous input-argument combinations.```

example

````sys = sparss(ltiSys)` converts the dynamic system model `ltiSys` to a first-order sparse state-space model.```

Input Arguments

expand all

State matrix, specified as an `Nx`-by-`Nx` sparse matrix, where `Nx` is the number of states. This input sets the value of property A.

Input-to-state matrix, specified as an `Nx`-by-`Nu` sparse matrix, where `Nx` is the number of states and `Nu` is the number of inputs. This input sets the value of property B.

State-to-output matrix, specified as an `Ny`-by-`Nx` sparse matrix, where `Nx` is the number of states and `Ny` is the number of outputs. This input sets the value of property C.

Input-to-output matrix, specified as an `Ny`-by-`Nu` sparse matrix, where `Ny` is the number of outputs and `Nu` is the number of inputs. This input sets the value of property D.

Mass matrix, specified as an `Nx`-by-`Nx` sparse matrix, where `Nx` is the number of states. This input sets the value of property E.

Sample time, specified as a scalar. For more information see the Ts property.

Dynamic system to convert to first-order sparse state-space form, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can convert include:

Output Arguments

expand all

Output system model, returned as a `sparss` model object.

Properties

expand all

State matrix, specified as an `Nx`-by-`Nx` sparse matrix, where `Nx` is the number of states.

Input-to-state matrix, specified as an `Nx`-by-`Nu` sparse matrix, where `Nx` is the number of states and `Nu` is the number of inputs.

State-to-output matrix, specified as an `Ny`-by-`Nx` sparse matrix, where `Nx` is the number of states and `Ny` is the number of outputs.

Input-to-output matrix, specified as an `Ny`-by-`Nu` sparse matrix, where `Ny` is the number of outputs and `Nu` is the number of inputs. `D` is also called as the static gain matrix which represents the ratio of the output to the input under steady state condition.

Mass matrix, specified as a `Nx`-by-`Nx` sparse matrix. `E` is the same size as `A`.

Differential algebraic equations (DAEs) are characterized by their differential index, which is a measure of their singularity. A linear DAE is of index ≤`1` if it can be transformed by congruence to the following form with `E11` and `A22` being invertible matrices.

`$\begin{array}{r}{E}_{11}{\stackrel{˙}{x}}_{1}={A}_{11}{x}_{1}+{A}_{12}{x}_{2}+{B}_{1}u\\ 0={A}_{21}{x}_{1}+{A}_{22}{x}_{2}+{B}_{2}u\end{array}$`

The index of the DAE is `0` if `x2` is empty. The index is `1` if `x2` is not empty. In other words, a linear DAE has structural index ≤`1` if it can be brought to the above form by row and column permutations of `A` and `E`. Some functionality, such as computing the impulse response of the system, is limited to DAEs with structural index less than 1.

For more information on DAE index, see Solve Differential Algebraic Equations (DAEs).

State partition information containing state vector components, interfaces between components and internal signal connecting components, specified as a structure array with the following fields:

• `Type` — Type includes component, signal or physical interface

• `Name` — Name of the component, signal or physical interface

• `Size` — Number of states or degrees of freedom in the partition

You can view the partition information of the sparse state-space model using `showStateInfo`. You can also sort and order the partitions in your sparse model using `xsort`.

Options for model analysis, specified as a structure with the following fields:

• `UseParallel` — Set this option `true` to enable parallel computing and `false` to disable it. Parallel computing is disabled by default. The `UseParallel` option requires a Parallel Computing Toolbox™ license.

• `DAESolver` — Use this option to select the type of Differential Algebraic Equation (DAE) solver. The available DAE solvers are:

• `'trbdf2'` — Fixed-step solver with an accuracy of `o(h^2)`, where `h` is the step size.[1]

• `'trbdf3'` — Fixed-step solver with an accuracy of `o(h^3)`, where `h` is the step size.

Reducing the step size increases accuracy and extends the frequency range where numerical damping is negligible. `'trbdf3'` is about 50% more computationally intensive than `'trbdf2'`

Internal delays in the model, specified as a vector. 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.

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 sample time `Ts`. For example, `InternalDelay = 3` means a delay of three sampling periods.

You can modify the values of internal delays using the property `InternalDelay`. However, the number of entries in `sys.InternalDelay` cannot change, because it is a structural property of the model.

Input delay for each input channel, specified as one of the following:

• Scalar — Specify the input delay for a SISO system or the same delay for all inputs of a multi-input system.

• `Nu`-by-1 vector — Specify separate input delays for input of a multi-input system, where `Nu` is the number of inputs.

For continuous-time systems, specify input delays in the time unit specified by the `TimeUnit` property. For discrete-time systems, specify input delays in integer multiples of the sample time, `Ts`.

Output delay for each output channel, specified as one of the following:

• Scalar — Specify the output delay for a SISO system or the same delay for all outputs of a multi-output system.

• `Ny`-by-1 vector — Specify separate output delays for output of a multi-output system, where `Ny` is the number of outputs.

For continuous-time systems, specify output delays in the time unit specified by the `TimeUnit` property. For discrete-time systems, specify output delays in integer multiples of the sample time, `Ts`.

Sample time, specified as:

• `0` for continuous-time systems.

• A positive scalar representing the sampling period of a discrete-time system. Specify `Ts` in the time unit specified by the `TimeUnit` property.

• `-1` for a discrete-time system with an unspecified sample time.

Note

Changing `Ts` does not discretize or resample the model. To convert between continuous-time and discrete-time representations, use `c2d` and `d2c`. To change the sample time of a discrete-time system, use `d2d`.

Time variable units, specified as one of the following:

• `'nanoseconds'`

• `'microseconds'`

• `'milliseconds'`

• `'seconds'`

• `'minutes'`

• `'hours'`

• `'days'`

• `'weeks'`

• `'months'`

• `'years'`

Changing `TimeUnit` has no effect on other properties, but changes the overall system behavior. Use `chgTimeUnit` to convert between time units without modifying system behavior.

Input channel names, specified as one of the following:

• A character vector, for single-input models.

• A cell array of character vectors, for multi-input models.

• `''`, no names specified, for any input channels.

Alternatively, you can assign input names for multi-input models using automatic vector expansion. For example, if `sys` is a two-input model, enter the following:

`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`.

Use `InputName` to:

• Identify channels on model display and plots.

• Extract subsystems of MIMO systems.

• Specify connection points when interconnecting models.

Input channel units, specified as one of the following:

• A character vector, for single-input models.

• A cell array of character vectors, for multi-input models.

• `''`, no units specified, for any input channels.

Use `InputUnit` to specify input signal units. `InputUnit` has no effect on system behavior.

Input channel groups, specified as a structure. Use `InputGroup` to assign the input channels of MIMO systems into groups and refer to each group by name. The field names of `InputGroup` are the group names and the field values are the input channels of each group. For example, enter the following to create input groups named `controls` and `noise` that include input channels `1` and `2`, and `3` and `5`, respectively.

```sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5];```

You can then extract the subsystem from the `controls` inputs to all outputs using the following.

`sys(:,'controls')`

By default, `InputGroup` is a structure with no fields.

Output channel names, specified as one of the following:

• A character vector, for single-output models.

• A cell array of character vectors, for multi-output models.

• `''`, no names specified, for any output channels.

Alternatively, you can assign output names for multi-output models using automatic vector expansion. For example, if `sys` is a two-output model, enter the following.

`sys.OutputName = 'measurements';`

The output names automatically expand to `{'measurements(1)';'measurements(2)'}`.

You can also use the shorthand notation `y` to refer to the `OutputName` property. For example, `sys.y` is equivalent to `sys.OutputName`.

Use `OutputName` to:

• Identify channels on model display and plots.

• Extract subsystems of MIMO systems.

• Specify connection points when interconnecting models.

Output channel units, specified as one of the following:

• A character vector, for single-output models.

• A cell array of character vectors, for multi-output models.

• `''`, no units specified, for any output channels.

Use `OutputUnit` to specify output signal units. `OutputUnit` has no effect on system behavior.

Output channel groups, specified as a structure. Use `OutputGroup`to assign the output channels of MIMO systems into groups and refer to each group by name. The field names of `OutputGroup` are the group names and the field values are the output channels of each group. For example, create output groups named `temperature` and `measurement` that include output channels `1`, and `3` and `5`, respectively.

```sys.OutputGroup.temperature = [1]; sys.OutputGroup.measurement = [3 5];```

You can then extract the subsystem from all inputs to the `measurement` outputs using the following.

`sys('measurement',:)`

By default, `OutputGroup` is a structure with no fields.

User-specified text that you want to associate with the system, specified as a character vector or cell array of character vectors. For example, `'System is MIMO'`.

User-specified data that you want to associate with the system, specified as any MATLAB data type.

System name, specified as a character vector. For example, `'system_1'`.

Sampling grid for model arrays, specified as a structure array.

Use `SamplingGrid` to track the variable values associated with each model in a model array.

Set the field names of the 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 must be numeric scalars, and all arrays of sampled values must match the dimensions of the model array.

For example, you can create an 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, you can create a 6-by-9 model array, `M`, by independently sampling two variables, `zeta` and `w`. The following code maps the `(zeta,w)` values to `M`.

```[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w)```

By default, `SamplingGrid` is a structure with no fields.

Object Functions

The following lists show functions you can use with `sparss` model objects.

expand all

 `mechss` Sparse second-order state-space model `getx0` Map initial conditions from a `mechss` object to a `sparss` object `full` Convert sparse models to dense storage `imp2exp` Convert implicit linear relationship to explicit input-output relation `inv` Invert dynamic system models `getDelayModel` State-space representation of internal delays
 `sparssdata` Access first-order sparse state-space model data `mechssdata` Access second-order sparse state-space model data `showStateInfo` State vector map for sparse model `spy` Visualize sparsity pattern of a sparse model
 `c2d` Convert model from continuous to discrete time `d2c` Convert model from discrete to continuous time `d2d` Resample discrete-time model
 `step` Step response plot of dynamic system; step response data `impulse` Impulse response plot of dynamic system; impulse response data `initial` System response to initial states of state-space model `lsim` Plot simulated time response of dynamic system to arbitrary inputs; simulated response data `bode` Bode plot of frequency response, or magnitude and phase data `nyquist` Nyquist plot of frequency response `nichols` Nichols chart of frequency response `sigma` Singular value plot of dynamic system `passiveplot` Compute or plot passivity index as function of frequency `dcgain` Low-frequency (DC) gain of LTI system `evalfr` Evaluate system response at specific frequency `freqresp` Evaluate system response over a grid of frequencies
 `interface` Specify physical connections between components of `mechss` model `xsort` Sort states based on state partition `feedback` Feedback connection of multiple models `parallel` Parallel connection of two models `append` Group models by appending their inputs and outputs `connect` Block diagram interconnections of dynamic systems `lft` Generalized feedback interconnection of two models (Redheffer star product) `series` Series connection of two models

Examples

collapse all

For this example, consider `sparseFOContinuous.mat` which contains sparse matrices for a continuous-time sparse first-order state-space model.

Extract the sparse matrices from `sparseFOContinuous.mat`.

`load('sparseFOContinuous.mat','A','B','C','D','E');`

Create the `sparss` model object.

`sys = sparss(A,B,C,D,E)`
```Sparse continuous-time state-space model with 1 outputs, 1 inputs, and 199 states. Use "spy" and "showStateInfo" to inspect model structure. Type "help sparssOptions" for available solver options for this model. ```

The output `sys` is a continuous-time `sparss` model object containing with 199 states, 1 input and 1 output.

You can use the `spy` command to visualize the sparsity of the `sparss` model object.

`spy(sys)`

For this example, consider `sparseFODiscrete.mat` which contains sparse matrices for a discrete-time sparse first-order state-space model.

Extract the sparse matrices from `sparseFODiscrete.mat`.

`load('sparseFODiscrete.mat','A','B','C','D','E','ts');`

Create the `sparss` model object.

`sys = sparss(A,B,C,D,E,ts)`
```Sparse discrete-time state-space model with 1 outputs, 1 inputs, and 398 states. Use "spy" and "showStateInfo" to inspect model structure. Type "help sparssOptions" for available solver options for this model. ```

The output `sys` is a discrete-time `sparss` model object containing with 398 states, 1 input and 1 output.

You can use the `spy` command to visualize the sparsity of the `sparss` model object.

`spy(sys)`

You can also view model properties of the sparss model object.

`properties('sparss')`
```Properties for class sparss: A B C D E Scaled StateInfo SolverOptions InternalDelay InputDelay OutputDelay InputName InputUnit InputGroup OutputName OutputUnit OutputGroup Notes UserData Name Ts TimeUnit SamplingGrid ```

Create a static gain MIMO sparse first-order state-space model.

Consider the following three-input, two-output static gain matrix:

`$D=\left[\begin{array}{ccc}1& 5& 7\\ 6& 3& 9\end{array}\right]$`

Specify the gain matrix and create the static gain sparse first-order state-space model.

```D = [1,5,7;6,3,9]; sys = sparss(D); size(sys)```
```Sparse state-space model with 2 outputs, 3 inputs, and 0 states. ```

For this example, consider `mechssModel.mat` that contains a `mechss` model object `ltiSys`.

Load the `mechss` model object from `mechssModel.mat`.

```load('mechssModel.mat','ltiSys'); ltiSys```
```Sparse continuous-time second-order model with 1 outputs, 1 inputs, and 872 degrees of freedom. Use "spy" and "showStateInfo" to inspect model structure. Type "help mechssOptions" for available solver options for this model. ```

Use the `sparss` command to convert to first-order sparse representation.

`sys = sparss(ltiSys)`
```Sparse continuous-time state-space model with 1 outputs, 1 inputs, and 1744 states. Use "spy" and "showStateInfo" to inspect model structure. Type "help sparssOptions" for available solver options for this model. ```

The resultant `sparss` model object `sys` has exactly double the number of states than the `mechss` object `ltisys` since the mass matrix `M` is full rank. If the mass matrix is not full rank then the number of states in the resultant `sparss` model when converting from a `mechss` model is between `n` and `2n`. Here, `n` is the number of nodes in the `mechss` model object.

For this example, consider `sparseFOSignal.mat` that contains a sparse first-order model. Define an actuator, sensor, and controller and connect them together with the plant in a feedback loop.

Load the sparse matrices and create the `sparss` object.

```load sparseFOSignal.mat plant = sparss(A,B,C,D,E,'Name','Plant');```

Next, create an actuator and sensor using transfer functions.

```act = tf(1,[1 2 3],'Name','Actuator'); sen = tf(1,[6 7],'Name','Sensor');```

Create a PID controller object for the plant.

`con = pid(1,1,0.1,0.01,'Name','Controller');`

Use the `feedback` command to connect the plant, sensor, actuator, and controller in a feedback loop.

`sys = feedback(sen*plant*act*con,1)`
```Sparse continuous-time state-space model with 1 outputs, 1 inputs, and 29 states. Use "spy" and "showStateInfo" to inspect model structure. Type "help sparssOptions" for available solver options for this model. ```

The resultant system `sys` is a `sparss` object since `sparss` objects take precedence over `tf` and `PID` model object types.

Use `showStateInfo` to view the component and signal groups.

`showStateInfo(sys)`
```The state groups are: Type Name Size ------------------------------- Component Sensor 1 Component Plant 20 Signal 1 Component Actuator 2 Signal 1 Component Controller 2 Signal 1 Signal 1 ```

Use `xsort` to sort the components and signals, and then view the component and signal groups.

```sysSort = xsort(sys); showStateInfo(sysSort)```
```The state groups are: Type Name Size ------------------------------- Component Sensor 1 Component Plant 20 Component Actuator 2 Component Controller 2 Signal 4 ```

Observe that the components are now ordered before the signal partition. The signals are now sorted and grouped together in a single partition.

You can also visualize the sparsity pattern of the resultant system using `spy`.

`spy(sysSort)`

References

[1] M. Hosea and L. Shampine. "Analysis and implementation of TR-BDF2." Applied Numerical Mathematics, vol. 20, no. 1-2, pp. 21-37, 1996.

Version History

Introduced in R2020b