# Identification of High-Order Nonlinear Coupled Systems Using a Data-Driven Approach
## 2 Mathematical Tools
### Modified SINDY Algorithm  
Now, the location of the candidate functions in the matrix \(\Xi_{0}\) is passed as a parameter to the modified SINDY function, as illustrated in the MATLAB code presented in Appendix A.5. The matrix \(\Xi\) obtained by applying the MATLAB function provided in Appendix A.5 to the data described in the previous section is:  
\[\Xi = \left[ \begin{array}{cccccccc}0&0&0&0&0&0\\ 1&0&0&0&0&0\\ 0&1&0&0&0&0\\ 0&0&1&0&0&0\\ 0&0&0&0&0&1\\ 0&0&0&1&0\\ 0&0&0&0&\[\begin{array}{cccccccc}0&0&4.725&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 14.32&0&0&0&0&0\\ 0&-14.29&0&0&0&0\\ 0&0&7.302&0&0&0\\ 0&0&0&8169.0&0&0\\ 0&0&0&-2.442&0&0\\ 0&0&0&0&5939&0\\ 0&0&0&0&-7.961&0\\ 0&0&0&0&4087\\ 0&0&0&0&0&0.09223\end{array}\end{array} . \tag{27}\]  
Unlike the matrix presented in (25), this matrix corresponds to the sparse identification of a high-order nonlinear system characterized by coupled dynamics, specifically exemplified in the context of drone dynamics. Then, the identified nonlinear system is given by:  
\[\dot{x}_{1} = x_{7} \tag{28}\] \[\dot{x}_{2} = x_{8}\] (29) \[\dot{x}_{3} = x_{9}\] (30) \[\dot{x}_{4} = x_{12}\] (31) \[\dot{x}_{5} = x_{11}\] (32) \[\dot{x}_{6} = x_{10}\] (33) \[\dot{x}_{7} = 14.32\beta_{1}(\sin(x_{4})\sin(x_{6})+\cos(x_{4})\cos(x_{6})sin(x _{5}))\] (34) \[\dot{x}_{8} = -14.29\beta_{1}(\cos(x_{4})\sin(x_{6})-\cos(x_{6})\sin(x_{4})\sin (x_{5}))\] (35) \[\dot{x}_{9} = 7.302\beta_{1}\cos(x_{5})\cos(x_{6})+4.725\] (36) \[\dot{x}_{10} = 8169\beta_{2}-2.442x_{11}x_{12}\] (37) \[\dot{x}_{2} = x_{8}\]0 (38) \[\dot{x}_{2} = x_{8}\]1  
Notice that the gravity value in Equation (36) is calculated as 4.725, which is 2.076 times smaller than 9.81. This implies that the entire equation is scaled by 2.076\({}^{-1}\). However, as per Equations (12)-(14), when the identified model is analyzed at the equilibrium, i.e., when all linear and angular displacements, velocities, and accelerations are zero, and the mass \(m\) is computed using Equations (34)-(36) multiplied by 2.076, it results in \(m=0.0698\), \(m=0.0699\), and \(m=0.0659\), respectively, which are very close to the nominal value found in the literature of \(m=0.068\)[29, 30]. Now, based on these equations, a linear stabilizer is designed. To achieve this, Equations (28)-(39) are linearized at the equilibrium \(x_{eq}=[0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0]^{T}\), resulting in:  
\[\dot{x}_{2} = x_{8}\]2with  
\[A=\left[ \begin{array}{cccccccccccc}0&0&0&0&0&0&1&0&0&0&0\\ 0&0&0&0&0&0&0&1&0&0&0&0\\ 0&0&0&0&0&0&0&1&0&0&0\\ 0&0&0&0&0&0&0&0&0&0&1\\ 0&0&0&0&0&0&0&0&0&1&0\\ 0&0&0&0&0&0&0&0&1.0&0&0\\ 0&0&0&0&-9.27&0&0&0&0&0&0&0\\ 0&0&0&0&0&9.247&0&0&0&0&0&0\\ 0&0&0&0&0&0&0&0&0&0&0\\ 0&0&0&0&0&0&0&0&0&0&0\\ 0&0&0&0&0&0&0&0&0&0&0\\ 0&0&0&0&0&0&0&0&0&0&0\end{array} \right], \tag{41}\]  
and  
\[B=\left[ \begin{array}{cccccccc}0&0&0&0&0&0&0&0&7.302&0&0&0\\ 0&0&0&0&0&0&0&0&8169&0&0\\ 0&0&0&0&0&0&0&0&0&5939&0\\ 0&0&0&0&0&0&0&0&0&4087\end{array} \right]^{T}. \tag{42}\]  
The stabilizer \(u=-Kx\) is obtained using the Linear Quadratic Regulator (LQR) approach, which combines the control energy and the state deviations in the cost function of the form:  
\[J=\int_{0}^{\infty}\left(x^{T}Qx+u^{T}Ru\right)dt, \tag{43}\]  
where \(Q\) and \(R\) are positive definite matrices determining the compromise between minimizing the state deviations and the control energy [31]. In this case, \(Q=I_{[12\times 12]}\), and \(R=1\times 10^{6}\cdot I_{[4\times 4]}\). Thus, with matrices \(A\), \(B\), \(Q\), and \(R\) as above, the gain \(K\) is computed using the MATLAB function \(lqr\), resulting in:  
\[K = \left[ \begin{array}{cccccccc}0&0&0.001&0&0&0\\ 0&0.001&0&0&0&0.006795\\ -0.001&0&0&0&0.007291&0\\ 0&0&0&0.001&0&0\\ 0&0&0&0.01658&0&0&0\\ 0&0.001571&0&0.001632&0&0\\ -0.001604&0&0&0&0.001859&0\\ 0&0&0&0&0&0.00122\end{array} \right] \tag{44}\]  
Then, the stabilizer \(u=-Kx\) is applied to the nonlinear model within the Simulink Support Package for Parrot Minidrones to assess the effectiveness of the identified model.