BlockWerk Documentation
A-B-C-D (z)

Discrete State-Space

Discrete

The Discrete State-Space block implements a discrete-time linear state-space system. At each sample instant it advances the internal state vector using the recurrence equations, then computes the output as a linear combination of the current state and input. The block is equivalent to the z-domain matrix transfer function H(z) = C(zI - A)^-1 B + D.

Typical uses include implementing discrete-time plant models, observer/estimator dynamics, pre-designed digital filters expressed in state-space form, and any linear system that has been discretised from a continuous-time design via zero-order hold or Tustin methods.

Simulate in BlockWerk

Interactive sandbox directly in your browser — zero installation, WASM-powered.

Simulate in BlockWerk →

Mathematical Model

x[k+1]=Ax[k]+Bu[k]y[k]=Cx[k]+Du[k]\begin{aligned} x[k+1] &= Ax[k] + Bu[k] \\ y[k] &= Cx[k] + Du[k] \end{aligned}

Where:

  • x[k] — state vector at step k (length n, the system order)
  • u[k] — input vector at step k (matches column count of B)
  • y[k] — output vector at step k (matches row count of C)
  • A — n×n state-transition matrix
  • B — n×m input matrix
  • C — p×n output matrix
  • D — p×m direct-feedthrough matrix
  • k — discrete time index; real time = k · sampleTime

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

First-order low-pass filter at 100 Hz

A discrete first-order low-pass with pole at z = 0.9, unit DC gain:

Step → DiscreteStateSpace → Display
       A=0.9  B=0.1  C=1  D=0  T=0.01s

Second-order system (double integrator, Euler)

Discretised double integrator with T = 0.01 s:

Force → DiscreteStateSpace → Position
        A=[1 0.01; 0 1]  B=[0.00005; 0.01]  C=[1 0]  D=0

Remarks & Best Practices

  • Matrix sizing: A must be square (n×n). B must have n rows. C must have n columns. D must have the same row count as C and the same column count as B. Mismatched dimensions will produce a simulation error.
  • Multi-input / multi-output: Connect multiple signals to the input port (multi-connect) for MIMO systems; the block stacks them into the u vector in connection order.
  • Stability: The system is stable only when all eigenvalues of A lie strictly inside the unit circle. An unstable A matrix will cause the state to grow without bound.
  • Discrete states: The block internally allocates up to 32 discrete state slots; keep system order at or below 32.
  • Sample time alignment: When mixing this block with other discrete blocks, set all sampleTime values consistently or insert a Rate Transition block at the boundary.

Related Components

  • RateTransition: Use to cross sample-rate boundaries when connecting this block to subsystems running at a different rate.
  • TransferFunction: Continuous-time equivalent; use when designing in s-domain before discretisation.
  • Integrator: Continuous-time state accumulation; use instead of DiscreteStateSpace when the global solver handles integration.