# How to shift state space models by equilibrium points using ss and lsim?

4 views (last 30 days)
Ashwin Vadivel on 28 Mar 2021
Commented: Ashwin Vadivel on 28 Mar 2021
Hi everybody,
I linearized the nonlinear ODEs describing the dynamics of the planar quadrotor at the equilibrium point: xe = [y1 z1 0 0 0 0]. Then I proceeded to put my equations in state space form x_dot = Ax + Bu and y = Cx. I obtained my A,B,C,D matrices and pass them to Matlab function ss like so:
Sys = ss(A,B,C,D). Then I pass it to lsim to simulate like so:
[Outputs, time, states] = lsim(sys, u, time, x0).
My question is: how do I make sure that all my states and my initial conditions are shifted by the equilibrium points? I understand that my state variables are now written in terms of deviation from the equilibrium point and so: y_tilde = y - ye, z_tilde = z - ze, and for the other 4 state variables x_tilde = x, since xe = 0 for all the other states.
Do I have to manually shift the initial condition x0 to make it x0_tilde before passing it to ss(A,B,C,D)? And how about the outputs from lsim do I have to shift those by xe? Please ask if I can clarify anything I understand how to define the state space system on paper but have no idea how matlab deals with it. Thanks!

Paul on 28 Mar 2021
The states, inputs, and outputs of Sys are all perturbations from the equilibrium solution. The intiial condition to lsim (x0) would then be an intiial perturbation from the equilibrium condition. The Outputs and States from the call to lsim are the perturbations to the equilibrium outputs and states. The input u to lsim is the perturbation to the equilibrium solution input.
Ashwin Vadivel on 28 Mar 2021
Yes makes perfect sense thanks for the help!