MATLAB state-space representation is a mathematical model of a physical system that uses matrices to describe the system's input, output, and state variables.
Here's a simple code snippet demonstrating how to define a state-space system in MATLAB:
A = [0 1; -2 -3]; % System matrix
B = [0; 1]; % Input matrix
C = [1 0]; % Output matrix
D = 0; % Feedthrough matrix
sys = ss(A, B, C, D); % Create state-space system
Introduction to State-Space Representation
What is State-Space?
State-space representation is a mathematical model used to describe the behavior of dynamic systems. It encompasses the internal states of a system and how they evolve over time based on inputs. This representation is crucial in control theory because it provides a framework for analyzing and designing systems that react to various inputs over time.
Applications of State-Space Models
State-space models are widely applicable across various fields such as engineering, robotics, economics, and biological systems. For example, in control engineering, state-space representation is employed to design controllers that can stabilize systems and ensure desired performance. In robotics, it helps in modeling the movements and states of robotic arms to achieve precise control.

Fundamental Concepts of State-Space Models
Key Components of State-Space Models
State-space models consist of several essential components:
- State Variables: These are variables that represent the current state of the system. For example, in a mechanical system, state variables could include position, velocity, and acceleration.
- Input Variables: These represent external influences on the system, such as forces, voltages, or any time-varying inputs.
- Output Variables: These are the measurable outputs of the system, which we aim to control or monitor.
- Disturbance Variables: These account for unexpected influences that may affect system performance.
Understanding these components assists in forming a complete representation of the dynamic behavior of the system being modeled.
State-Space Equations
State-space models are represented mathematically by two primary equations:
-
State Equation: The state evolution is described by the equation \( \dot{x} = Ax + Bu \), where:
- \( x \) is the state vector.
- \( A \) is the system matrix, dictating how states evolve without input.
- \( B \) is the input matrix, showing how input affects the state.
- \( u \) is the input vector.
-
Output Equation: The relationship between state and output is given by \( y = Cx + Du \), where:
- \( y \) is the output vector.
- \( C \) is the output matrix.
- \( D \) is the feedthrough (or direct transmission) matrix, indicating the direct influence of input on output.
Collectively, these equations allow us to describe complex systems in a structured manner.
State-Space vs. Transfer Function
While both state-space and transfer function methods are used to represent dynamic systems, they have different strengths. State-space representation is advantageous for multiple-input, multiple-output (MIMO) systems and when dealing with internal states. In contrast, transfer functions are often easier to use for linear systems with single-input, single-output (SISO) applications. MATLAB provides functions to convert between these two representations, allowing the user to leverage the strengths of each as necessary.

Creating State-Space Models in MATLAB
Introduction to MATLAB Environment
MATLAB offers a comprehensive environment for creating and analyzing state-space models. It includes built-in functions and toolboxes that are tailored specifically for control systems. This rich functionality facilitates system modeling, simulation, and design without the need for extensive programming knowledge.
Creating State-Space Objects
In MATLAB, you can create state-space models using the `ss` function. Here’s an example of how to define a system with matrices A, B, C, and D:
A = [0 1; -2 -3];
B = [0; 1];
C = [1 0];
D = 0;
sys = ss(A, B, C, D);
This command creates a state-space system object `sys` that you can subsequently analyze and simulate.
Visualizing State-Space Systems
Understanding how a state-space model behaves requires visualization. One essential aspect is observing the system's response to inputs:
-
Step Response: You can plot the step response of the state-space system using the `step` function. This response indicates how the system behaves when subjected to a sudden change in input.
figure; step(sys); title('Step Response of the State-Space System');
-
Impulse Response: Similarly, you can visualize the impulse response using `impulse`, showing how the system reacts to an instantaneous input.
figure; impulse(sys); title('Impulse Response of the State-Space System');
Both plots provide valuable insights into the transient and steady-state behavior of the system.

Analyzing State-Space Models
Stability Analysis
Stability is a critical factor in control system design. For a state-space system to be stable, all eigenvalues of matrix A must have negative real parts. You can assess stability in MATLAB by examining the eigenvalues:
eig(A) % Checking eigenvalues of the matrix A
A system is considered stable if all eigenvalues lie in the left half of the complex plane.
Controllability and Observability
Understanding the controllability and observability of a system is pivotal in control design:
-
Controllability: A system is controllable if it is possible to steer its state variables to zero (or any desired state) using appropriate inputs. You can check controllability using the Controllability Matrix as follows:
C = ctrb(A, B); rank(C); % Rank to assess controllability
A full rank of the controllability matrix indicates that the system is controllable.
-
Observability: A system is observable if its internal states can be inferred by observing its outputs. You can assess observability using the Observability Matrix:
O = obsv(A, C); rank(O); % Rank to assess observability
Again, complete rank means the system is observable.

Designing Controllers and Observers
State Feedback Control
State feedback control involves using the current state of the system to compute control inputs. Designing state feedback can stabilize a system by placing the closed-loop poles in desired locations. In MATLAB, you can use the `place` function:
K = place(A, B, desired_poles);
Choosing appropriate poles is strategic, as they affect the speed and stability of the system response.
Observer Design
A state observer is a method to estimate the internal state of a system based on its output. The Luenberger observer is a popular choice, defined by:
L = place(A', C', desired_observer_poles)';
Again, the placement of the observer poles influences the response time of the observer and its ability to track the actual system states accurately.

Simulation and Practical Applications
Implementing a Simple Control System Example
Combining the discussed methodologies, one can implement a control system, evaluate its response, and iterate on controller designs to meet specific performance criteria. For instance, you might develop a system to control the position of a cart on a track using a feedback loop originating from a state-space model.
Real-World Applications and Case Studies
State-space models are vital in various industries. For example, in aerospace engineering, they are used to model the dynamics of aircraft and design autopilot systems. In automotive engineering, state-space frameworks help engineer complex vehicle dynamics for better steering and stability control. A case study could detail the modeling of a quadcopter, encompassing its dynamics from a state-space perspective to achieve precise flight control.

Conclusion
In this comprehensive guide, we covered the foundational aspects of MATLAB state-space representation, its mathematical underpinnings, and practical implementation. By understanding and utilizing state-space models, one can model, analyze, and design advanced control systems effectively. We encourage you to explore more complex scenarios and continue expanding your knowledge in this crucial domain of control engineering.

Additional Resources
Recommended MATLAB Toolboxes
Consider exploring the Control System Toolbox, which offers extensive features for linear system analysis, including state-space representation, for more advanced designs and analyses.
Further Reading and References
For deeper insights, consult textbooks on control systems, online courses, and research papers that delve into advanced topics in state-space modeling and control theory.