# 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.

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}$