System Modeling
Differential Equation Models
Physical systems are described by ordinary differential equations (ODEs) derived from first principles.
Mechanical (translational): Newton's second law
m*x'' + b*x' + k*x = F(t)
Electrical (RLC circuit): Kirchhoff's laws
L*i'' + R*i' + (1/C)*i = v'(t)
Electromechanical (DC motor):
J*theta'' + b*theta' = K_t * i
L*i' + R*i = V - K_e * theta'
The analogy between mechanical and electrical domains enables unified treatment:
- Force <-> Voltage, Velocity <-> Current, Mass <-> Inductance, Damping <-> Resistance, Spring <-> 1/Capacitance
State-Space Representation
The most general LTI representation uses first-order vector differential equations:
x'(t) = A*x(t) + B*u(t) (state equation)
y(t) = C*x(t) + D*u(t) (output equation)
Where:
x(t)is the n-dimensional state vectoru(t)is the m-dimensional input vectory(t)is the p-dimensional output vectorA(n x n): system/state matrixB(n x m): input matrixC(p x n): output matrixD(p x m): feedforward matrix (often zero)
Example -- Mass-spring-damper: with states x1 = position, x2 = velocity:
A = [ 0 1 ] B = [ 0 ]
[-k/m -b/m ] [1/m ]
C = [1 0] D = [0]
Transfer Function from State-Space
Taking the Laplace transform (zero initial conditions):
G(s) = C*(sI - A)^(-1)*B + D
The characteristic polynomial is det(sI - A), whose roots are the eigenvalues of A (= poles of the transfer function).
Important: state-space can represent systems that transfer functions cannot (e.g., when there are pole-zero cancellations hiding internal dynamics).
Linearization
For a nonlinear system x' = f(x, u), linearize about an equilibrium point (x_0, u_0) where f(x_0, u_0) = 0:
delta_x' = A * delta_x + B * delta_u
Where:
A = df/dx |_(x0, u0) (Jacobian of f with respect to x)
B = df/du |_(x0, u0) (Jacobian of f with respect to u)
Example -- Inverted pendulum with state [theta, theta_dot]:
f1 = theta_dot
f2 = (g/l)*sin(theta) - (b/ml^2)*theta_dot + (1/ml^2)*u
Linearized about theta=0:
A = [0 1 ] B = [ 0 ]
[g/l -b/(ml^2) ] [1/(ml^2)]
Linearization is valid only for small deviations from the operating point.
Canonical Forms
Controllable Canonical Form (CCF)
For transfer function G(s) = (b_{n-1}s^{n-1} + ... + b_0) / (s^n + a_{n-1}s^{n-1} + ... + a_0):
A_ccf = [ 0 1 0 ... 0 ]
[ 0 0 1 ... 0 ]
[ ... ]
[ -a_0 -a_1 -a_2 ... -a_{n-1}]
B_ccf = [0, 0, ..., 1]^T
C_ccf = [b_0, b_1, ..., b_{n-1}]
Observable Canonical Form (OCF)
A_ocf = A_ccf^T, B_ocf = C_ccf^T, C_ocf = B_ccf^T
Diagonal (Modal) Canonical Form
When A has distinct eigenvalues lambda_i, the transformation T = [v_1, v_2, ..., v_n] (eigenvector matrix) yields:
A_diag = diag(lambda_1, lambda_2, ..., lambda_n)
For repeated eigenvalues, use Jordan canonical form with Jordan blocks.
Similarity Transformations
Any state-space realization can be transformed via z = T*x:
A_new = T*A*T^(-1), B_new = T*B, C_new = C*T^(-1), D_new = D
The transfer function is invariant under similarity transformations. Eigenvalues of A are preserved.
Controllability and Observability
Controllability matrix:
C_ctrl = [B, A*B, A^2*B, ..., A^(n-1)*B]
System is controllable iff rank(C_ctrl) = n.
Observability matrix:
O = [C; C*A; C*A^2; ...; C*A^(n-1)]
System is observable iff rank(O) = n.
Duality: (A, B) controllable iff (A^T, B^T) observable.
Kalman decomposition: any system can be decomposed into four subsystems -- controllable-observable, controllable-unobservable, uncontrollable-observable, uncontrollable-unobservable. Only the controllable-observable part appears in the transfer function.
System Identification
When first-principles modeling is impractical, identify models from input-output data.
Parametric Methods
ARX model (Auto-Regressive with eXogenous input):
A(q)*y(k) = B(q)*u(k) + e(k)
where A(q) = 1 + a_1*q^(-1) + ... + a_n*q^(-n) and q^(-1) is the delay operator.
Estimated via least squares: minimize sum(e(k)^2).
ARMAX adds a moving average noise model: A(q)*y(k) = B(q)*u(k) + C(q)*e(k).
Subspace Identification
Directly estimates state-space matrices (A, B, C, D) from data using SVD of block Hankel matrices of input-output data. Methods include N4SID, MOESP, CVA.
Frequency-Domain Identification
Apply sinusoidal inputs at various frequencies, measure gain and phase to construct empirical Bode plots. Fit rational transfer function models to the data.
Practical Considerations
- Persistent excitation: input must be sufficiently rich (e.g., PRBS, multisine)
- Validation: use separate data sets for identification and validation
- Model order selection: use AIC, BIC, or cross-validation
- Bias-variance tradeoff: higher-order models fit better but generalize worse
State-Space Solution
The solution to x' = Ax + Bu is:
x(t) = e^(At)*x(0) + integral_0^t e^(A(t-tau))*B*u(tau) d_tau
The matrix exponential e^(At) is the state transition matrix Phi(t):
Phi(t) = e^(At) = I + At + (At)^2/2! + ...
Computed via eigendecomposition: if A = V*Lambda*V^(-1), then e^(At) = V*e^(Lambda*t)*V^(-1).