BlockWerk Documentation
A-B-C-D

StateSpace

Continuous

The StateSpace block implements a general state-space linear system described by matrices A, B, C, D:

x' = Ax + Bu    (state equation)
y  = Cx + Du    (output equation)

This is the most general form of linear time-invariant (LTI) systems and is fundamental to modern control theory.

Simulate in BlockWerk

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

Simulate in BlockWerk →

Mathematical Model

x˙=Ax+Buy=Cx+Du\begin{aligned} \dot{x} &= Ax + Bu \\ y &= Cx + Du \end{aligned}

where:

  • x ∈ ℝⁿ: state vector (n states)
  • u ∈ ℝᵐ: input vector (m inputs)
  • y ∈ ℝᵖ: output vector (p outputs)
  • A: n×n state matrix
  • B: n×m input matrix
  • C: p×n output matrix
  • D: p×m feedthrough matrix

Where:

  • A: n×n state matrix
  • B: n×m input matrix
  • C: p×n output matrix
  • D: p×m feedthrough matrix

Inputs & Outputs

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

Parameters

Parameters Label Type Default Description
A A Matrix (state) matrix -1
B B Matrix (input) matrix 1
C C Matrix (output) matrix 1
D D Matrix (feedthrough) vector 0
initialState Initial State (comma-sep) vector 0

Usage Examples

Example 1: First-Order System

A simple exponential decay system with time constant τ = 1:

Parameters:

  • A: "-1"
  • B: "1"
  • C: "1"
  • D: "0"

This represents: ẋ = -x + u, y = x (or any state)

Example 2: Second-Order Mass-Spring System

m·ẍ + c·ẋ + k·x = u

Let x₁ = position, x₂ = velocity. Then:

ẋ₁ = x₂
ẋ₂ = -k/m·x₁ - c/m·x₂ + 1/m·u
y = x₁ (output position)

Parameters (m=1, c=2, k=1):

  • A: "0 1; -1 -2"
  • B: "0; 1"
  • C: "1 0"
  • D: "0"

Example 3: MIMO System (2 inputs, 2 outputs)

A: "0 1 0; 0 0 1; -2 -3 -1"
B: "0 0; 1 0; 0 1"
C: "1 0 0; 0 1 0"
D: "0 0; 0 0"

Remarks & Best Practices

  • Dimension consistency: Matrix dimensions must satisfy A(n×n), B(n×m), C(p×n), D(p×m) or the block outputs zero
  • Euler stability: Forward Euler integration requires Δt < 2/|λ_max|; reduce sample time if simulation diverges
  • MIMO support: Full multi-input, multi-output capability; use comma-separated initial states for multi-state systems
  • State order: For n > 20 states numerical precision may degrade; consider model reduction
  • Feedthrough: If D ≠ 0 the output depends directly on the input (instantaneous response), which can create algebraic loops

Related Components