DiscreteStateSpace Block
Discrete-time state-space realization: x[k+1]=Ax[k]+Bu[k], y[k]=Cx[k]+Du[k]
Open DiscreteStateSpace in BlockWerk →# Discrete State-Space Block
Description
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.
Mathematical Model
x[k+1] = A·x[k] + B·u[k]
y[k] = C·x[k] + D·u[k]
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 matrixB— n×m input matrixC— p×n output matrixD— p×m direct-feedthrough matrixk— discrete time index; real time = k · sampleTime
Parameters
A
State-transition matrix. Enter as a space- or comma-separated list for a 1-D case, or use MATLAB-style row notation ([a11, a12; a21, a22]) for higher-order systems. Default: 0.9 (scalar, single-state integrator-like system).
B
Input matrix mapping the input vector to state derivatives. Dimensions must be compatible with A (n rows) and the number of input signals (m columns). Default: 1.
C
Output matrix mapping the state vector to outputs. Row count determines the number of output signals. Default: 1.
D
Direct-feedthrough matrix. Set to 0 for a strictly proper system (no instantaneous input-to-output path). Dimensions must match C rows × B columns. Default: 0.
initialState
Initial state vector x[0]. Must have length equal to the number of rows in A. Default: 0.
sampleTime
Sample period in seconds. All four matrix equations are evaluated once every sampleTime seconds. Must be a positive non-zero value. Default: 0.01 s (100 Hz).
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
- 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
sampleTimevalues consistently or insert a Rate Transition block at the boundary.
See Also
- 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.