A-B-C-D (z)

Discrete State-Space

Discrete
Run the live example Free · no sign-up · runs in your browser

The DiscreteStateSpace block models linear time-invariant (LTI) systems in discrete-time state-space representation. At each discrete sample interval TsT_s, the block updates an internal state vector x[k]\mathbf{x}[k] using the state-transition matrix A\mathbf{A} and input coupling matrix B\mathbf{B}, then computes the output vector y[k]\mathbf{y}[k] using the output matrix C\mathbf{C} and feedthrough matrix D\mathbf{D}.

This block features an interactive augmented matrix spreadsheet editor ([A | B; C | D]) in the Property Editor, allowing you to add or remove states (nn), inputs (mm), and outputs (pp) visually while automatically resizing coupled matrices and the initial state vector x[0]\mathbf{x}[0]. It also provides live unit-circle eigenvalue stability analysis (∣λi∣<1|\lambda_i| < 1), controllability/observability diagnostics, and a full Advanced State-Space Analysis Dashboard.

Mathematical Model

The discrete-time linear state-space difference equations are:

x[k+1]=Ax[k]+Bu[k]y[k]=Cx[k]+Du[k]\begin{aligned} \mathbf{x}[k+1] &= \mathbf{A} \mathbf{x}[k] + \mathbf{B} \mathbf{u}[k] \\ \mathbf{y}[k] &= \mathbf{C} \mathbf{x}[k] + \mathbf{D} \mathbf{u}[k] \end{aligned}

where:

  • x[k]∈Rn\mathbf{x}[k] \in \mathbb{R}^n is the state vector at discrete time step kk.
  • u[k]∈Rm\mathbf{u}[k] \in \mathbb{R}^m is the input vector.
  • y[k]∈Rp\mathbf{y}[k] \in \mathbb{R}^p is the output vector.
  • A∈Rn×n\mathbf{A} \in \mathbb{R}^{n \times n} is the discrete state-transition matrix.
  • B∈Rn×m\mathbf{B} \in \mathbb{R}^{n \times m} is the input matrix.
  • C∈Rp×n\mathbf{C} \in \mathbb{R}^{p \times n} is the output measurement matrix.
  • D∈Rp×m\mathbf{D} \in \mathbb{R}^{p \times m} is the direct feedthrough matrix.
  • kk is the integer sample index (t=k⋅Tst = k \cdot T_s).

The equivalent pulse transfer function matrix in the complex zz-plane is:

H(z)=C(zI−A)−1B+D\mathbf{H}(z) = \mathbf{C}(z\mathbf{I} - \mathbf{A})^{-1}\mathbf{B} + \mathbf{D}

Inputs & Outputs

Direction ID Label Type Status
→ In u Input(s) number Required
← Out y Output(s) number Output

Parameters

Parameters Label Type Default Description
A A Matrix vector 0.9
B B Matrix vector 1
C C Matrix vector 1
D D Matrix vector 0
initialState Initial State vector 0
sampleTime Sample Time number 0.01

Usage Examples

Example 1: Discretized First-Order RC Filter

A continuous first-order lowpass filter x˙=−1τx+1τu\dot{x} = -\frac{1}{\tau} x + \frac{1}{\tau} u discretized via zero-order hold with time constant τ=0.1\tau = 0.1 s and sample period Ts=0.01T_s = 0.01 s. With A=e−Ts/τ=0.9048\mathbf{A} = e^{-T_s/\tau} = 0.9048, B=1−A=0.0952\mathbf{B} = 1 - \mathbf{A} = 0.0952, C=1\mathbf{C} = 1, and D=0\mathbf{D} = 0, the discrete block precisely tracks the continuous exponential step response without numerical drift.

Example 2: Discrete Double-Integrator Motion Model

A kinematic positioning mechanism with states x=[p,v]T\mathbf{x} = [p, v]^T (position and velocity) driven by acceleration command uu. Specifying Ts=0.02T_s = 0.02 s, A=[10.0201]\mathbf{A} = \begin{bmatrix} 1 & 0.02 \\ 0 & 1 \end{bmatrix}, B=[0.00020.02]\mathbf{B} = \begin{bmatrix} 0.0002 \\ 0.02 \end{bmatrix}, C=[10]\mathbf{C} = \begin{bmatrix} 1 & 0 \end{bmatrix}, and D=0\mathbf{D} = 0. Feeding a step acceleration input yields a smooth parabolic position trajectory.

Remarks & Best Practices

  • Interactive Matrix Grid & Dashboard: Use the + / − dimension controls in the Property Editor to add or remove states, inputs, and outputs without manually counting semicolons, and click Open Advanced Analysis Dashboard to inspect discrete step response, Bode plot, and zz-plane pole-zero locations.
  • Asymptotic Stability: The discrete system is asymptotically stable if and only if all eigenvalues of A\mathbf{A} lie strictly within the unit circle of the complex plane (∣λi(A)∣<1|\lambda_i(\mathbf{A})| < 1). Eigenvalues on or outside the unit circle produce oscillatory or diverging responses.
  • Dimensional Compatibility: The dimensions must satisfy: A\mathbf{A} is n×nn \times n, B\mathbf{B} has nn rows, C\mathbf{C} has nn columns, and D\mathbf{D} has dimensions p×mp \times m.
  • Direct Feedthrough and Algebraic Loops: When D≠0\mathbf{D} \neq 0, the block creates an instantaneous algebraic path from input to output. If placed in an un-delayed feedback loop, an algebraic loop may occur.
  • Sample Rate Coordination: Always align sampleTime with connected discrete blocks or use RateTransition blocks to safely cross sample-rate domains.

Related Components

  • StateSpace: Continuous-time linear state-space block integrated by the ODE solver.
  • DiscreteTransferFunction: Pulse transfer function representation H(z)=B(z)/A(z)H(z) = B(z)/A(z).
  • RateTransition: Safe rate-buffering element between different sample time domains.
  • UnitDelay: Fundamental single-sample discrete delay block (z−1z^{-1}).