# State space modeling with disturbances using Matlab

I am doing a project which involves modeling a quadcopter in state space form using matlab. I first had to linearize the quadcopter equations of motion, and now have to implement them in a matlab state space system.

In order to do this I need to put the linearized differential equations in this form:

$$\dot{x} = Ax + Bu$$ $$y = Cx$$

The issue I am having is that one of my state equations has a constant term because of acceleration due to gravity. The equation in question is shown below, with Vz, v1^2, v2^2, v3^2, and v4^2 all being state variables, and everything else constants:

$$\dot{V_{z}} = -\frac{K_{d}}{m}V_{z} + \frac{KC_{m}}{m}(v_{1}^{2} + v_{2}^{2} + v_{3}^{2} + v_{4}^{2}) - g$$

How am I supposed to accompany this term (-g) into matlab's state space model?

My only thought is to use the state space model with identifiable parameters, and include the constant in the disturbance matrix K, but I am unsure of how to go about that, never having used a disturbance matrix before.

## 1 Answer

You have a nonzero operating point. If you had chosen an equilibrium operating point, this situation would not have occurred.

With the equation you have given, if you choose the states as $\left\{x_1=\frac{g m}{K_d}+V_z,x_2=v_1^2,x_3=v_2^2,x_4=v_3^2,x_5=v_4^2\right\}$ you get a linear state equation:

$\dot{x}_1=\frac{K \left(x_2+x_3+x_4+x_5\right) C_m}{m}-\frac{x_1 K_d}{m}$

I am guessing this would upset some other state equation. Then you have to consider all the states and equations together. But, as I said before the best approach is to do this at the linearization step.

• So what you are saying is that I should redefine my state variables in order to remove the constant term from my state equations? Or that I mislinearized the equations and should redo that stage? – Nick Apr 21 '15 at 14:15
• You typically redefine the state variables and inputs as deviations from some operating point during linearization. That was not done correctly, so you have to redefine again at this stage. My suggestion was to define (choose) the state and input variables once correctly. – Suba Thomas Apr 21 '15 at 14:46