State Space
ContinuousThe StateSpace block implements general continuous-time linear time-invariant (LTI) dynamic systems formulated in matrix state-space notation. Representing plants via internal state vectors (), input vectors (), and output measurement vectors (), it is the cornerstone of modern control theory, multivariable (MIMO) systems, Kalman filtering, Linear Quadratic Regulators (LQR), and structural modal analysis. The block parses standard MATLAB/matrix syntax, supports multiple inputs and outputs, and integrates state trajectories using high-order WASM ODE solvers.
Mathematical Model
The continuous state-space system is described by the first-order vector differential state equation and algebraic output equation:
where:
- is the -dimensional state vector
- is the -dimensional input vector
- is the -dimensional output vector
- is the state transition matrix
- is the input coupling matrix
- is the output measurement matrix
- is the direct feedthrough matrix
The eigenvalues of matrix define the system poles:
The system is asymptotically stable if and only if all eigenvalues of have strictly negative real parts (). In the frequency domain, the equivalent transfer function matrix is given by:
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: Inverted Pendulum on a Cart Linearized State-Space Model
Modeling an inverted pendulum around its upright unstable equilibrium with state vector . Setting A = "0 1 0 0; 0 -0.1 2.5 0; 0 0 0 1; 0 -0.2 28.5 0", B = "0; 1.5; 0; 3.0", C = "1 0 0 0; 0 0 1 0" (measuring cart position and pendulum angle), D = "0; 0", and initialState = "0, 0, 0.05, 0". This enables testing state-feedback stabilization () from an initial tilt of .
Example 2: Two-Mass Resonant Drive Transmission
Modeling a dual-inertia motor-load coupling with states for motor velocity, load velocity, and shaft twist angle. Configuring A = "-0.2 0 -5; 0 -0.1 5; 1 -1 0", B = "1; 0; 0", C = "0 1 0", and D = "0". The system captures resonant torsional oscillations and shaft torque transmission during motor acceleration steps.
Remarks & Best Practices
- Matrix Dimension Consistency: Matrix dimensions must be strictly consistent: if is , then must be , must be , and must be . Dimension mismatches trigger a configuration error.
- Multivariable MIMO Support: Supports multi-input multi-output architectures; input and output ports automatically adapt to the column count of and row count of .
- High-Order Stiff Solvers: Evaluated in Rust/WASM across explicit Runge-Kutta (RK4, RK45) and stiff implicit TR-BDF2 solvers, ensuring numerical stability even for stiff matrices with widely separated eigenvalues.
- External Reset Action: Asserting a positive value on the optional
resetport resets the state vector back to the initial conditions specified ininitialState.
Frequently Asked Questions (FAQ)
Q: How to select weighting matrices Q and R for Linear Quadratic Regulator (LQR)?
Use Bryson's Rule as an engineering baseline: set diagonal elements to and , where is the maximum acceptable deviation for state and is the maximum actuator excursion. This normalizes all state penalties and control efforts to non-dimensional units, allowing intuitive trade-offs between response speed and actuator effort.
Q: How does State-Space compare to Transfer Function representation?
Transfer functions describe single-input single-output (SISO) input-output dynamics under zero initial conditions, hiding internal plant dynamics. State-Space models () naturally handle multi-input multi-output (MIMO) systems, non-zero initial conditions, and internal observability and controllability structures.
Related Components
- TransferFunction: Single-input single-output transfer function .
- ZeroPole: Zero-pole-gain factored representation .
- Integrator: Continuous single-state integrator.
- SecondOrderSystem: Second-order continuous oscillator model.