Karlo mentioned to use the state space of $[q,\dot{q}]^T$ this allows you to write the system as a first order differential equation of state space. If $X$ were the state space, you could write $\dot{X} = f(X)$. As far as the work you need to do, you write that
$$
X = \begin{bmatrix} q\\ \dot{q}\end{bmatrix}
$$
the derivative of $\frac{dq}{dt}=\dot{q}$ which is part of X and $\frac{d\dot{q}}{dt}=\ddot{q}$ which can be solved for algebraically in the ODE.
$$
\frac{dX}{dt} = \begin{bmatrix} \dot{q}\\ KM^{-1}q \end{bmatrix}
$$
for the undamped system. If you intend on using a numerical solver in matlab (maybe ode45
) it would look something like this assuming all your system parameters are defined as matrices with similar names and IC
is the initial condition and tmin
and tmax
are time bounds you're interested in for a solution.
dxdt = @(x) [x(2); M\K*x(1)];
[q,t] = ode45(dxdt, [tmin, tmax], IC);
ode45
specifically expects this form: where the first parameter is a vector that is the derivative of a coordinate/state space vector. Notice we would have the same code if we instead used something that wasn't second order by notation, but the condition that $\dot{s}=t$ makes it second order.
$$
\frac{dX}{dt} = \frac{d}{dt}\begin{bmatrix} s \\ t \end{bmatrix} = \begin{bmatrix} t \\ KM^{-1}s \end{bmatrix}
$$
Using this technique, we can write any system that is a Nth order differential equation as a first order equation of an Nth order state space.
Edit: After seeing your most recent comment, your state space could be written as:
$$
X = \begin{bmatrix} x\\y\\u \\ \dot{x}\\\dot{y}\\\dot{u}\end{bmatrix}
$$
I think I misunderstood what you meant by using matlab and maple. Your inputs are known\controlled values, so $F(t)$ and $T(t)$ along with the system parameters, like $K$, outputs are system behavior, like $x,y,u$ and their derivatives, what you don't know upon the formulation of the equation, but you don't need maple to construct the equation for you, it's just the ones you find from the algebra.
Lastly, I somehow didn't notice your controller forces $T(t)$ and $F(t)$ and didn't write them into the first parameter of the solver, but those can be written in as well, as they are. It would just be that $\ddot{q}=M^{-1}(Kq-T(t)-F(t))$.