In a first step the routine coo_2_vec replaces the elements of the state vector x (phi1, phi2,phi3, phi_1, phi_2, phi_3) by the array x(1:6), this makes the application of the generated routine easier. In the second step a Matlab-function is generated with the input variables x and t. The name of the generated function is stored in the variables f.M and f.h. Listing 2 shows the procedure for M(t, q) and h(t, q, ˙ q) (lines 7 and 8). The functions generated for the positions and rotations (lines 1 to 6) are needed later for the animation of the results.