Engineering · Control Theory · State-Space Models

Control System Matrix Simulator

Build and simulate a linear control system using its state-space matrices. Explore how system dynamics, control inputs and measured outputs interact. Examine step responses, stability, controllability and observability in one interactive engineering tool.

\(\dot{x}=Ax+Bu \qquad y=Cx+Du\)
Interactive engineering tool

State-Space Control Simulator

Edit the model matrices, choose an input signal and simulate the system response.

2-state · SISO model
A mechanical system with position and velocity as its states.
A — System matrix
Describes internal system dynamics.
B — Input matrix
Describes how the control input affects the states.
C — Output matrix
Selects the measured output from the states.
D — Feedthrough
Direct input-to-output contribution.

Initial state vector

Input signal

Open-loop stability
—
Based on eigenvalues of A
Controllability
—
Rank of [B AB]
Observability
—
Rank of [C; CA]

System response graph

The graph displays both internal states and the measured output over time. The output includes the direct feedthrough term Du.

State x₁ State x₂ Output y
Final state x₁
—
Final state x₂
—
Final output y
—

Response data

Time (s) Input u State x₁ State x₂ Output y
Run the simulator to display results.

Numerical method: fourth-order Runge–Kutta (RK4). This tool is intended for educational exploration of two-state, continuous-time, linear time-invariant systems. Results depend on the model and numerical step size.

Understanding the Control System Matrices

State-space modeling is a fundamental method in modern control engineering. Instead of describing a dynamic system only through an input-output differential equation, it represents the system using a set of first-order equations. This makes it especially useful for systems with multiple internal variables, interacting components and several inputs or outputs.

\[ \boxed{\dot{x}(t)=Ax(t)+Bu(t)} \] \[ \boxed{y(t)=Cx(t)+Du(t)} \]

In these equations:

  • x(t) is the state vector, containing the internal variables that describe the system at time \(t\).
  • u(t) is the control input applied to the system.
  • y(t) is the measured or observed output.
  • A is the system or state matrix.
  • B is the input matrix.
  • C is the output matrix.
  • D is the direct feedthrough matrix.

The simulator uses two states, one input and one output. Therefore, its matrix dimensions are \(A\in\mathbb{R}^{2\times2}\), \(B\in\mathbb{R}^{2\times1}\), \(C\in\mathbb{R}^{1\times2}\), and \(D\in\mathbb{R}^{1\times1}\).

The Role of Each Matrix in Engineering

1. System matrix A

The matrix A describes how the internal state variables influence one another when no external input is applied. Its eigenvalues determine the natural modes of a continuous-time linear system and provide an important first test of open-loop stability.

\[ A= \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22} \end{bmatrix} \]

For example, in a mechanical system, position and velocity are related. The first row may express how velocity changes position, while the second row describes acceleration caused by restoring forces and damping.

2. Input matrix B

Matrix B describes how an external actuator, voltage source, applied force or other control signal enters the state equations. A state can be affected indirectly through the system dynamics even if its corresponding entry in B is zero.

3. Output matrix C

Matrix C determines which combination of internal states is measured. A sensor may measure position, velocity, current, temperature or a combination of variables. The internal state vector and measured output are not necessarily identical.

4. Feedthrough matrix D

Matrix D represents an instantaneous input-to-output relationship. If D is zero, the output depends only on the states. If D is nonzero, the applied input contributes directly to the measured output as well.

How the Simulator Calculates System Response

A state-space model describes how the state changes over time. Given an initial state and an input signal, the simulator numerically integrates the differential equation and calculates the corresponding output at each time step.

Continuous-time solution

For a constant matrix A and a specified input, the exact state solution can be written as:

\[ x(t)=e^{At}x(0)+ \int_0^t e^{A(t-\tau)}Bu(\tau)\,d\tau \]

The first term describes the response caused by the initial state. The integral describes the accumulated effect of the external input. The matrix exponential \(e^{At}\) is known as the state-transition matrix.

Numerical integration using RK4

The interactive tool uses the classical fourth-order Runge–Kutta method. For a state derivative \(f(t,x)=Ax+Bu(t)\), one integration step is:

\[ \begin{aligned} k_1 &= f(t_n,x_n)\\ k_2 &= f(t_n+h/2,x_n+hk_1/2)\\ k_3 &= f(t_n+h/2,x_n+hk_2/2)\\ k_4 &= f(t_n+h,x_n+hk_3)\\ x_{n+1} &= x_n+\frac{h}{6}(k_1+2k_2+2k_3+k_4) \end{aligned} \]

Here, \(h\) is the integration time step. Smaller steps generally improve numerical resolution, although the appropriate step size also depends on the fastest dynamics in the model. RK4 is a numerical approximation, not an exact solution.

Engineering Example 1: Mass–Spring–Damper System

A mass attached to a spring and damper is a classic mechanical control system. Its motion is governed by Newton's second law:

\[ m\ddot{q}+c\dot{q}+kq=F(t) \]

Define the states as position and velocity: \(x_1=q\) and \(x_2=\dot{q}\). The resulting state-space model is:

\[ \begin{bmatrix} \dot{x}_1\\ \dot{x}_2 \end{bmatrix} = \begin{bmatrix} 0&1\\ -k/m&-c/m \end{bmatrix} \begin{bmatrix} x_1\\x_2 \end{bmatrix} + \begin{bmatrix} 0\\1/m \end{bmatrix}F(t) \]

If the measured output is displacement, then \(C=[1\quad0]\) and \(D=0\). Select the mass–spring–damper preset to explore this model. The default example uses \(m=1\), \(k=2\), and \(c=0.8\) in consistent units.

Engineering Example 2: Series RLC Circuit

An electrical RLC circuit contains a resistor, inductor and capacitor. For a series circuit driven by an input voltage, choose capacitor charge \(q\) and current \(i\) as the state variables.

\[ \dot{q}=i \] \[ \dot{i}=-\frac{1}{LC}q-\frac{R}{L}i+\frac{1}{L}v(t) \]

The state-space matrices are:

\[ A= \begin{bmatrix} 0&1\\ -1/(LC)&-R/L \end{bmatrix}, \quad B= \begin{bmatrix} 0\\1/L \end{bmatrix} \]

The RLC preset uses normalized illustrative parameters \(L=1\), \(C=0.5\), and \(R=0.8\). Its input is a voltage-like signal and its output is the first state, charge. Change C and D if you want to model another measured quantity.

Engineering Example 3: Simplified DC Motor

A simplified DC motor can be represented using angular position and angular velocity as states. In a basic model with normalized parameters, the electrical dynamics and motor torque can be approximated by a second-order state-space model.

The motor preset in this tool is an illustrative two-state model with position and speed states. It is useful for exploring coupled dynamics and input response, but it is not a complete motor model: a detailed electromechanical design may need a third state for armature current, as well as resistance, inductance, torque constant and back-EMF terms.

Understanding Stability Through Eigenvalues

The eigenvalues of A describe the natural modes of a continuous-time linear time-invariant system. For an asymptotically stable system, every eigenvalue must have a strictly negative real part.

  • Asymptotically stable: all eigenvalues have negative real parts. The unforced response decays toward zero.
  • Unstable: at least one eigenvalue has a positive real part. Some unforced responses grow exponentially.
  • Marginal or boundary case: eigenvalues lie on the imaginary axis with no positive real part. Additional analysis is needed, particularly for repeated eigenvalues and Jordan blocks.
Important: This is an open-loop stability test for the matrix A. It does not prove that a closed-loop controller is stable, nor does it account for actuator saturation, nonlinearities, delays or model uncertainty.

Controllability: Can the System Be Driven?

Controllability asks whether an appropriate input can move the system between arbitrary states in finite time. For a two-state, single-input system, the controllability matrix is:

\[ \mathcal{C}= \begin{bmatrix} B&AB \end{bmatrix} \]

The system is completely controllable if:

\[ \operatorname{rank}(\mathcal{C})=2 \]

If the rank is less than two, at least one state direction cannot be independently reached using the available input. This matters when choosing actuator locations and designing state-feedback controllers.

Observability: Can the Internal State Be Reconstructed?

Observability asks whether the initial internal state can be determined from the measured output over time, assuming the system model and input are known. The two-state observability matrix is:

\[ \mathcal{O}= \begin{bmatrix} C\\CA \end{bmatrix} \]

The system is completely observable if:

\[ \operatorname{rank}(\mathcal{O})=2 \]

A system may be controllable but not observable, or observable but not controllable. These are different properties: one concerns what inputs can achieve, while the other concerns what can be inferred from outputs.

Where State-Space Matrix Models Are Used

  • Mechanical engineering: vibration analysis, suspension systems, robotic joints and motion control.
  • Electrical engineering: RLC circuits, power converters, motor drives and electrical networks.
  • Aerospace engineering: aircraft dynamics, attitude control, flight stabilization and spacecraft guidance.
  • Automotive engineering: vehicle dynamics, active suspension, cruise control and steering systems.
  • Industrial automation: process control, temperature regulation, servo systems and actuator control.
  • Robotics: manipulator dynamics, state estimation, trajectory tracking and feedback control.

Continuous-Time and Discrete-Time Control Models

Physical systems are often modeled in continuous time, while digital controllers operate at discrete sampling instants. A discrete-time state-space model is written as:

\[ x[k+1]=A_dx[k]+B_du[k] \] \[ y[k]=C_dx[k]+D_du[k] \]

Under a zero-order-hold assumption, where the input remains constant between samples with sampling period \(T_s\), the exact discrete matrices are:

\[ A_d=e^{AT_s} \] \[ B_d=\int_0^{T_s}e^{A\tau}B\,d\tau \]

The integral expression for \(B_d\) remains valid even when A is singular. The continuous-time simulator on this page does not perform this discretization; it numerically integrates the continuous model.

How to Use This Control System Simulator

  1. Choose a model preset, such as the mass–spring–damper or RLC circuit.
  2. Inspect or edit the entries of A, B, C and D.
  3. Set the initial values of the two internal states.
  4. Select a unit step, sine, pulse or zero input.
  5. Set the input amplitude, simulation duration and integration resolution.
  6. Click Simulate system to calculate the response.
  7. Review the graph, final state values, output and response table.
  8. Compare the controllability and observability results when changing B or C.

Use the custom model option to experiment with your own two-state matrices. Keep the units consistent: the numerical model does not automatically convert between meters, seconds, newtons, volts or other engineering units.

Limitations and Engineering Considerations

This tool is designed for learning and preliminary exploration. It assumes a continuous-time, linear, time-invariant model with two states, one input and one output. It does not automatically identify a physical plant, design a feedback controller, estimate model parameters or validate experimental measurements.

Real engineering systems may include nonlinear behavior, constraints, disturbances, sensor noise, actuator limits, transport delays and parameter uncertainty. Before using a model for an engineering decision, verify its equations, units, assumptions and numerical results against appropriate analysis and testing.

Frequently Asked Questions

1. What is a state-space control system?

It is a mathematical representation of a dynamic system using first-order differential equations. The state-space form describes internal states, external inputs and measured outputs through A, B, C and D matrices.

2. What does the A matrix represent?

A describes the internal dynamics of the system. Its eigenvalues are central to understanding the natural modes and open-loop stability of a continuous-time linear model.

3. What is the difference between B and C?

B maps external inputs into changes in the internal states. C maps the internal states into measured outputs. B is related to actuation; C is related to sensing.

4. Why is the D matrix sometimes zero?

D is zero when there is no direct instantaneous path from the input to the measured output. The output then depends on the state vector through C.

5. Does controllability mean the system is stable?

No. Controllability describes whether inputs can steer the states. Stability describes how the system behaves over time without corrective feedback. A system can be controllable and unstable.

6. Can a system be controllable but not observable?

Yes. Controllability and observability are separate properties. A system may be fully controllable while some internal state information cannot be reconstructed from its measured outputs.

7. What input signals can I simulate?

This simulator supports unit-step, sine-wave, rectangular-pulse and zero-input signals. The selected amplitude and signal parameters determine the applied input.

8. Can I use the results to design a real controller?

Use the results for education and preliminary analysis, not as stand-alone validation for a real controller. Practical controller design requires a validated plant model, design specifications, constraints, robustness analysis and appropriate testing.

Explore More Matrix and Engineering Tools

Continue exploring matrix methods used in control theory, numerical engineering and dynamic system analysis.

Further Reading and Technical References

These resources provide additional theory and engineering context for state-space modeling, stability, controllability and observability.