I have the following system: $m\cdot\frac{dx^2}{dt^2}=-k(x-lo)-\frac{dx}{dt}\cdot d+m\cdot g$ It represents a mass with a spring and a damper. It is easy to solve using NDSolve but I'm trying to solve it using matrices. (Because if we represent the system using state equations, we can use some transformations, like diagonalization or triangularization so the time of computation is reduced). I tried using regular matrices but it doesn't work. Is there any way to do this? The system after an order reduction is:
$ \begin{bmatrix} x1'(t) \\ x2'(t) \\ \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ \frac{-k}{m} & \frac{-d}{m} \\ \end{bmatrix} \begin{bmatrix} x1 \\ x2 \\ \end{bmatrix}+ \begin{bmatrix} 0\\ \frac{1}{m}\\ \end{bmatrix} f(t) + \begin{bmatrix} 0\\ \frac{kl_o}{m}+g\\ \end{bmatrix} $
where $f(t)=15u(t-5)$ (u(t) is the unit step function).
I have tried this:
lo = 0.50; m = 1.5; k = 20; d = 3; g = 9.8;
A = {{0, 1}, {-k/m, -m}}
z[t_] = 15*HeavisideTheta[t - 5];
b = {{0}, {1/m}};
γ = {{0}, {(k*lo)/m + g}};
S = A*{{x0[t]}, {x1[t]}} + b*z[t] + γ
eqns = {{x0'[t]}, {x1'[t]}}
NDSolve[{eqns == A*{{x0[t]}, {x1[t]}} + b*z[t] + γ ,
x0[0] == 0, x1[0] == 0}, {x0[t], x1[t]}, {t, 0, 10}]


HeavisideTheta[]is intended for symbolic use only; for numerics, like in your situation, please useUnitStep[]. Also, matrix-vector multiplication is.(Dot[]), not*(Times[]). – J. M.'s missing motivation Aug 03 '17 at 01:47k,m,lo,ghave? – Carl Woll Aug 03 '17 at 02:30