You are on page 1of 10

Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

sparss
Sparse (rst-order state-space model
Since R2020b

Description
Use sparss to represent sparse descriptor state-space models using matrices obtained from your (nite 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 eGcient 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 (rst-order sparse state-space model is represented in the following form:

dx
E = A x(t) + B u(t)
dt
y(t) = C x(t) + D u(t)

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 speci(c 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.

For more information, see Sparse Model Basics.

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

sys = sparss(A,B,C,D,E) creates a continuous-time (rst-order sparse state-space model object of the example
following form:

dx
E = A x(t) + B u(t)
dt
y(t) = C  x(t) + D u(t)

For instance, consider a plant with Nx states, Ny outputs, and Nu inputs. The (rst-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.

https://it.mathworks.com/help/control/ref/sparss.html Page 1 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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:

E  x[k + 1] = A x[k] + B u[k]


y[k] = C x[k] + D u[k]

To leave the sample time unspeci(ed, 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 (rst-order sparse state-space model using one or
more name-value pair arguments. Use this syntax with any of the previous input-argument combinations.

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

Input Arguments expand all

A — State Matrix
 Nx-by-Nx sparse matrix

B — Input-to-state matrix
 Nx-by-Nu sparse matrix

C — State-to-output matrix
 Ny-by-Nx sparse matrix

D — Input-to-output matrix
 Ny-by-Nu sparse matrix

E — Mass matrix
 Nx-by-Nx sparse matrix

ts — Sample time
 scalar

ltiSys — Dynamic system to convert to <rst-order sparse state-space form


 dynamic system model | model array

Output Arguments expand all

sys — Output system model


 sparss model object

https://it.mathworks.com/help/control/ref/sparss.html Page 2 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

Properties expand all

A — State matrix
 Nx-by-Nx sparse matrix

B — Input-to-state matrix
 Nx-by-Nu sparse matrix

C — State-to-output matrix
 Ny-by-Nx sparse matrix

D — Input-to-output matrix
 Ny-by-Nu sparse matrix

E — Mass matrix
 Nx-by-Nx sparse matrix

StateInfo — State partition information


 structure array

SolverOptions — Options for model analysis


 structure

InternalDelay — Internal delays in the model


 vector

InputDelay — Input delay


 0 (default) | scalar | Nu-by-1 vector

OutputDelay — Output delay


 0 (default) | scalar | Ny-by-1 vector

Ts — Sample time
 0 (default) | positive scalar | -1

TimeUnit — Time variable units


 'seconds' (default) | 'nanoseconds' | 'microseconds' | 'milliseconds' | 'minutes' | 'hours' | 'days' |
'weeks' | 'months' | 'years' | ...

InputName — Input channel names


 '' (default) | character vector | cell array of character vectors

InputUnit — Input channel units


 '' (default) | character vector | cell array of character vectors

https://it.mathworks.com/help/control/ref/sparss.html Page 3 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

InputGroup — Input channel groups


 structure

OutputName — Output channel names


 '' (default) | character vector | cell array of character vectors

OutputUnit — Output channel units


 '' (default) | character vector | cell array of character vectors

OutputGroup — Output channel groups


 structure

Notes — User-speci<ed text


 {} (default) | character vector | cell array of character vectors

UserData — User-speci<ed data


 [] (default) | any MATLAB data type

Name — System name


 '' (default) | character vector

SamplingGrid — Sampling grid for model arrays


 structure array

Object Functions
The following lists show functions you can use with sparss model objects. expand all

 Modeling

 Data Access

 Model Transformation

 Time and Frequency Response

 Model Interconnection

Examples collapse all

 Continuous-Time Sparse First-Order Model

https://it.mathworks.com/help/control/ref/sparss.html Page 4 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

For this example, consider sparseFOContinuous.mat which contains sparse Open in MATLAB Online
matrices for a continuous-time sparse (rst-order state-space model.

Extract the sparse matrices from sparseFOContinuous.mat. Copy Command  

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)

 Discrete-Time Sparse First-Order Model

For this example, consider sparseFODiscrete.mat which contains sparse


matrices for a discrete-time sparse (rst-order state-space model. Open in MATLAB Online
Extract the sparse matrices from sparseFODiscrete.mat.
Copy Command  

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

Create the sparss model object.

https://it.mathworks.com/help/control/ref/sparss.html Page 5 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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')

https://it.mathworks.com/help/control/ref/sparss.html Page 6 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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

 MIMO Static Gain Sparse First-Order Model

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


Open in MATLAB Online
Consider the following three-input, two-output static gain matrix:

[6 3 9]
1 5 7 Copy Command  
D=

Specify the gain matrix and create the static gain sparse (rst-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.

 Convert Second-Order Sparse Model to First-Order Sparse Model Representation

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


object ltiSys. Open in MATLAB Online
Load the mechss model object from mechssModel.mat.
Copy Command  

load('mechssModel.mat','ltiSys');
ltiSys

https://it.mathworks.com/help/control/ref/sparss.html Page 7 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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 (rst-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.

 Sparse First-Order Model in a Feedback Loop

For this example, consider sparseFOSignal.mat that contains a sparse (rst-


order model. De(ne an actuator, sensor, and controller and connect them together Open in MATLAB Online
with the plant in a feedback loop.

Load the sparse matrices and create the sparss object. Copy Command  

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)

https://it.mathworks.com/help/control/ref/sparss.html Page 8 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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)

https://it.mathworks.com/help/control/ref/sparss.html Page 9 of 10
Sparse first-order state-space model - MATLAB - MathWorks Italia 03/04/23, 10:14 AM

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

See Also
sparssdata | mechss | showStateInfo | xsort | full | getx0 | spy | Descriptor State-Space (Simulink)

Topics
Sparse Model Basics

https://it.mathworks.com/help/control/ref/sparss.html Page 10 of 10

You might also like