State-Space Representation
State-space representation is the working language of simulation because it expresses a dynamic model as first-order differential equations. Higher-order equations, coupled component models, and nonlinear systems can all be written in this form. Once a model is in state-space form, a numerical solver only needs a function that maps the current time, current state, and current input to the state derivative.
This representation also separates model structure from implementation. MATLAB functions such as ode45, ss, lsim, and step operate naturally on state equations, and Simulink's Integrator and State-Space blocks are built around the same idea. Transfer functions are useful for linear input-output analysis, but state-space models keep the internal variables visible, which is essential when validating simulations against measured states or checking physical constraints.
Definitions
A continuous-time nonlinear state-space model is
Here is the state vector, is the input vector, and is the output vector. The model order is , the number of states.
The linear time-invariant state-space model is
The matrix dimensions are
An initial condition is part of the simulation problem. Without it, the derivative rule is incomplete because many possible trajectories satisfy the same differential equation.
State variables are not unique. A second-order equation can be represented by position and velocity, by position and momentum, or by transformed modal coordinates. Different choices can improve numerical conditioning, interpretability, or compatibility with measured data.
Key results
Any ordinary differential equation that can be solved for the highest derivative can be rewritten as first-order state equations. For
choose and . Then
For an LTI model, the unforced solution is
With input , the solution is
This formula is important even when we do not compute the matrix exponential directly. It shows that the eigenvalues of control natural modes and that input history is filtered through the same state transition matrix.
The transfer function matrix of an LTI state-space model is
This connects state-space simulation to the Laplace-domain tools used in signals, systems, and control. The poles of are usually eigenvalues of , although cancellations can hide internal modes from a particular input-output channel.
For simulation work, state ordering should be documented as carefully as parameter values. A solver only sees a vector of numbers, so the meaning of x(1) and x(2) must be recoverable from comments, variable names, plots, or block labels. A common professional practice is to keep a short state table with symbol, units, initial value, and physical interpretation. That table prevents mistakes when the derivative function is edited later or when a Simulink model is compared with a MATLAB script.
State scaling also matters. If one state is a voltage near and another is a position near , a single absolute tolerance can make the solver over-resolve one state and under-resolve another. In MATLAB this can be handled with vector absolute tolerances, nondimensional states, or a scaled state transformation. In Simulink, the same issue appears when logged signals have very different magnitudes and the solver reports tiny steps or inaccurate zero crossings. A state-space representation is therefore not only a mathematical format; it is also a numerical interface.
Visual
| Form | Main use | Strength | Limitation |
|---|---|---|---|
| Higher-order ODE | Compact scalar physics | Familiar for simple mechanical or electrical models | Not directly accepted by general ODE solvers |
| State-space | Simulation and multi-input systems | Handles coupled states and nonlinearities | State choice must be made carefully |
| Transfer function | Linear input-output analysis | Easy poles, zeros, frequency response | Hides internal state and initial-condition structure |
| Block diagram | Simulink implementation | Shows signal flow and feedback | Can obscure equations if blocks are undocumented |
Worked example 1: Convert an RLC circuit to state-space form
Problem: A series RLC circuit is driven by an input voltage . Let , , and . Choose capacitor voltage and inductor current as states. Derive and for output .
- Choose states:
- Use capacitor and inductor relations:
In a series circuit the current through all elements is , so
- Apply Kirchhoff's voltage law:
- Solve for :
so
- Assemble matrices:
Checked answer: dimensions are consistent: is , is , and is . A unit step in voltage should make approach at steady state, because the capacitor is open-circuit in DC and no voltage is dropped across or after transients.
Simulink description: use a State-Space block with the , , , and matrices, or build the two equations with Sum, Gain, and Integrator blocks. The time-response plot should show capacitor voltage rising toward the input with possible overshoot depending on damping.
Worked example 2: Build a controllable canonical realization
Problem: The transfer function
is to be simulated in state-space form. Construct a realization using and , and check the step steady state.
- Convert the transfer function to a differential equation:
Assuming zero initial conditions, this corresponds to
- Choose states:
- Write first-order equations:
- Assemble output:
Thus
- Check the unit-step steady state. At equilibrium, . From the first equation, . From the second,
Checked answer: the DC gain is , matching the equilibrium. The time-response plot should show a stable second-order response because the poles of are , both in the left half-plane.
Simulink description: this system can be implemented with one Transfer Fcn block using numerator [3] and denominator [1 4 5], or with two Integrator blocks in state form. The state implementation is better when internal velocity-like state must be inspected.
Code
clear; clc; close all;
% RLC state-space model
R = 4; L = 0.5; Ccap = 0.1;
A1 = [0, 1/Ccap; -1/L, -R/L];
B1 = [0; 1/L];
C1 = [1, 0];
D1 = 0;
sys_rlc = ss(A1, B1, C1, D1);
% Transfer function realization
A2 = [0 1; -5 -4];
B2 = [0; 3];
C2 = [1 0];
D2 = 0;
sys_second = ss(A2, B2, C2, D2);
t = linspace(0, 8, 500);
figure;
subplot(2,1,1);
step(sys_rlc, t); grid on;
title('RLC capacitor voltage response');
subplot(2,1,2);
step(sys_second, t); grid on;
title('Second-order realization response');
The MATLAB ss command creates LTI state-space objects that can be plotted directly. For nonlinear or time-varying systems, replace ss with a derivative function and integrate with ode45, ode15s, or another solver. In Simulink, the equivalent compact implementation is a State-Space block; the expanded implementation is an integrator bank with feedback gains matching the rows of and feedthrough gains matching .
Common pitfalls
- Using the output as the only state for a second-order model. The derivative of the output is also needed unless the model has been reduced for a valid reason.
- Confusing and dimensions. maps inputs into state derivatives; maps states into outputs.
- Assuming every transfer function realization exposes the same internal variables. Realizations can be mathematically equivalent but physically different.
- Forgetting direct feedthrough when the output algebraically depends on the input.
- Ignoring initial conditions when comparing a state-space simulation to a transfer-function step response. Many transfer-function commands default to zero initial state.
- Treating hidden pole-zero cancellations as harmless. A canceled internal unstable mode can still be dangerous if it corresponds to a real state.