linearize a system given the point of equilibrium in matlab

To linearize a system in Matlab given the point of equilibrium, you must follow these steps:

  1. Define the equations of your system using symbolic variables:
main.m
syms x1 x2 u
f1 = x2;
f2 = -0.1*x2 - sin(x1) + u;
50 chars
4 lines

where x1 and x2 are the states of the system, and u is the input.

  1. Find the point of equilibrium by solving for x1 and x2 when u=0:
main.m
eq = solve(f1==0, f2==0, x1, x2);
x1eq = eq.x1
x2eq = eq.x2
60 chars
4 lines
  1. Calculate the Jacobian matrix of the system at the equilibrium point:
main.m
J = jacobian([f1; f2], [x1; x2]);
Jeq = subs(J, [x1; x2; u], [x1eq; x2eq; 0]);
79 chars
3 lines
  1. Verify that Jeq is non-singular. If it is singular, then the linearization process will not work at this point.
main.m
det(Jeq)
9 chars
2 lines
  1. Linearize the system by linearizing the equations around the equilibrium point:
main.m
A = double(subs(J, [x1; x2; u], [x1eq; x2eq; 0]));
B = double(subs([0; 1], [x1; x2; u], [x1eq; x2eq; 0]));
C = [1 0];
D = 0;
sys = ss(A,B,C,D);
144 chars
6 lines

The resulting sys is a state-space model of the linearized system around the equilibrium point.

related categories

gistlibby LogSnag