---
url: /dyad/dev/stdlib/BlockComponents/components/Continuous.StateSpace.md
description: >-
  Dyad Continuous.StateSpace docs.  Linear state-space system with operating
  point support.
---

# `Continuous.StateSpace` {#Continuous.StateSpace}

Linear state-space system with operating point support.

Implements a linear, time-invariant state-space system of the form:

$$\dot{x} = Ax + B(u - u_0)$$

$$y = Cx + D(u - u_0) + y_0$$

where:

* `A` is the system matrix (nx × nx)

* `B` is the input matrix (nx × nu)

* `C` is the output matrix (ny × nx)

* `D` is the feedthrough matrix (ny × nu)

* `x` is the state vector (nx × 1)

* `u` is the input vector (nu × 1)

* `y` is the output vector (ny × 1)

* `u0` is the input operating point

* `y0` is the output operating point

The operating point feature allows the system to operate around a specific steady-state condition, which is useful for linearization around an equilibrium.

## Usage {#Usage}

`BlockComponents.Continuous.StateSpace(A=fill(0.0, nx, nx), B=fill(1.0, nx, nu), C=fill(1.0, ny, nx), D=fill(0.0, ny, nu), x0=fill(0.0, nx), u0=fill(0.0, nu), y0=fill(0.0, ny))`

## Parameters: {#Parameters:}

| Name |                  Description | Units |     Default value |
| ----:| ----------------------------:| -----:| -----------------:|
| `nx` |    Dimension of state vector |     – |                 2 |
| `nu` |             Number of inputs |     – |                 1 |
| `ny` |            Number of outputs |     – |                 1 |
|  `A` |      System matrix (nx × nx) |     – | fill(0.0, nx, nx) |
|  `B` |       Input matrix (nx × nu) |     – | fill(1.0, nx, nu) |
|  `C` |      Output matrix (ny × nx) |     – | fill(1.0, ny, nx) |
|  `D` | Feedthrough matrix (ny × nu) |     – | fill(0.0, ny, nu) |
| `x0` |         Initial state vector |     – |     fill(0.0, nx) |
| `u0` |        Input operating point |     – |     fill(0.0, nu) |
| `y0` |       Output operating point |     – |     fill(0.0, ny) |

## Connectors {#Connectors}

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Variables {#Variables}

| Name |  Description | Units |
| ----:| ------------:| -----:|
|  `x` | State vector |     – |
| `Δu` |              |     – |
| `Δy` |              |     – |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{{\Delta}u}\_{1}\left( t \right) &= u\_{1}\left( t \right) - \mathtt{u0}*{1} \\
\mathtt{{\Delta}y}\_{1}\left( t \right) &= y\_{1}\left( t \right) - \mathtt{y0}*{1} \\
\frac{\mathrm{d}x\_{1}\left( t \right)}{\mathrm{d}t} &= A\_{1,1} ~ x\_{1}\left( t \right) + A\_{1,2} ~ x\_{2}\left( t \right) + B\_{1,1} ~ \mathtt{{\Delta}u}\_{1}\left( t \right) \\
\frac{\mathrm{d}x\_{2}\left( t \right)}{\mathrm{d}t} &= A\_{2,1} ~ x\_{1}\left( t \right) + A\_{2,2} ~ x\_{2}\left( t \right) + B\_{2,1} ~ \mathtt{{\Delta}u}\_{1}\left( t \right) \\
\mathtt{{\Delta}y}\_{1}\left( t \right) &= C\_{1,1} ~ x\_{1}\left( t \right) + C\_{1,2} ~ x\_{2}\left( t \right) + D\_{1,1} ~ \mathtt{{\Delta}u}\_{1}\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Linear state-space system with operating point support.

Implements a linear, time-invariant state-space system of the form:

```math
\dot{x} = Ax + B(u - u_0)
```
```math
y = Cx + D(u - u_0) + y_0
```

where:
- `A` is the system matrix (nx × nx)
- `B` is the input matrix (nx × nu)
- `C` is the output matrix (ny × nx)
- `D` is the feedthrough matrix (ny × nu)
- `x` is the state vector (nx × 1)
- `u` is the input vector (nu × 1)
- `y` is the output vector (ny × 1)
- `u0` is the input operating point
- `y0` is the output operating point

The operating point feature allows the system to operate around a specific
steady-state condition, which is useful for linearization around an equilibrium.
"""
component StateSpace
  "Input connectors"
  u = [RealInput() for i in 1:nu] {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output connectors"
  y = [RealOutput() for i in 1:ny] {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Dimension of state vector"
  structural parameter nx::Integer = 2
  "Number of inputs"
  structural parameter nu::Integer = 1
  "Number of outputs"
  structural parameter ny::Integer = 1
  "System matrix (nx × nx)"
  parameter A::Real[nx, nx] = fill(0.0, nx, nx)
  "Input matrix (nx × nu)"
  parameter B::Real[nx, nu] = fill(1.0, nx, nu)
  "Output matrix (ny × nx)"
  parameter C::Real[ny, nx] = fill(1.0, ny, nx)
  "Feedthrough matrix (ny × nu)"
  parameter D::Real[ny, nu] = fill(0.0, ny, nu)
  "Initial state vector"
  parameter x0::Real[nx] = fill(0.0, nx)
  "Input operating point"
  parameter u0::Real[nu] = fill(0.0, nu)
  "Output operating point"
  parameter y0::Real[ny] = fill(0.0, ny)
  "State vector"
  variable x::Real(stateSelect = StateSelect.Prefer)[nx]
  variable Δu::Real[nu]
  variable Δy::Real[ny]
relations
  initial x = x0
  Δu = u - u0
  Δy = y - y0
  "State equation: dx/dt = A*x + B*(u - u0)"
  der(x) = A * x + B * Δu
  "Output equation: y = C*x + D*(u - u0) + y0"
  Δy = C * x + D * Δu
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/StateSpace.svg"}
  }
}
end
````

````dyad
"""
Linear state-space system with operating point support.

Implements a linear, time-invariant state-space system of the form:

```math
\dot{x} = Ax + B(u - u_0)
```
```math
y = Cx + D(u - u_0) + y_0
```

where:
- `A` is the system matrix (nx × nx)
- `B` is the input matrix (nx × nu)
- `C` is the output matrix (ny × nx)
- `D` is the feedthrough matrix (ny × nu)
- `x` is the state vector (nx × 1)
- `u` is the input vector (nu × 1)
- `y` is the output vector (ny × 1)
- `u0` is the input operating point
- `y0` is the output operating point

The operating point feature allows the system to operate around a specific
steady-state condition, which is useful for linearization around an equilibrium.
"""
component StateSpace
  "Input connectors"
  u = [RealInput() for i in 1:nu] {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output connectors"
  y = [RealOutput() for i in 1:ny] {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Dimension of state vector"
  structural parameter nx::Integer = 2
  "Number of inputs"
  structural parameter nu::Integer = 1
  "Number of outputs"
  structural parameter ny::Integer = 1
  "System matrix (nx × nx)"
  parameter A::Real[nx, nx] = fill(0.0, nx, nx)
  "Input matrix (nx × nu)"
  parameter B::Real[nx, nu] = fill(1.0, nx, nu)
  "Output matrix (ny × nx)"
  parameter C::Real[ny, nx] = fill(1.0, ny, nx)
  "Feedthrough matrix (ny × nu)"
  parameter D::Real[ny, nu] = fill(0.0, ny, nu)
  "Initial state vector"
  parameter x0::Real[nx] = fill(0.0, nx)
  "Input operating point"
  parameter u0::Real[nu] = fill(0.0, nu)
  "Output operating point"
  parameter y0::Real[ny] = fill(0.0, ny)
  "State vector"
  variable x::Real(stateSelect = StateSelect.Prefer)[nx]
  variable Δu::Real[nu]
  variable Δy::Real[ny]
relations
  initial x = x0
  Δu = u - u0
  Δy = y - y0
  "State equation: dx/dt = A*x + B*(u - u0)"
  der(x) = A * x + B * Δu
  "Output equation: y = C*x + D*(u - u0) + y0"
  Δy = C * x + D * Δu
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/StateSpace.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Integrator`](Continuous.StateSpace.md)

  * [`StateSpace`](Continuous.StateSpace.md)

  * [`StateSpace`](Continuous.StateSpace.md)

  * [`Step`](Continuous.StateSpace.md)

  * [`Terminator`](Continuous.StateSpace.md)
