2 DOF Spring Mass Damper with NDsolve and Equation of Motion in Matrix Form

I'll preface this with the fact that I have no idea what I'm doing. I'm new to Mathematica, I've only used it to solve simple ODEs with NDsolve. I'm trying to solve a 2DOF system now with with matrices instead of constants in the eqn of motion. Thanks for any help in advance.

m = {{2, 0}, {0, 1}};
c = {{3, -.5}, {-.5, .5}};
k = {{4, -1}, {-1, 1}};
initu = u[0] == {{0}, {.1}};
initv = u'[0] == {{1}, {0}};
u[t_] := {{u1[t]}, {u2[t]}};
sol =
NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}},
initu, initv}, u, {t, 0, 100}]

{{u -> u}}

{{u -> u}}
Plot[Evaluate[u[t] /. sol], {x, 0, 100}]

{{u -> u}}

• Could you tell me how to do that? Nov 28, 2014 at 17:11
• use this command reference.wolfram.com/language/ref/Quit.html (in separate cell) Nov 28, 2014 at 17:15
• Ok I think I that part fixed. Now my solution doesn't look right. I edited in the original post, getting "u->u" Nov 28, 2014 at 17:19
• I'd be happy to, I don't see where to do that though Nov 28, 2014 at 22:36

Change u to u[t] in the call to NDSolve

m = {{2, 0}, {0, 1}};
c = {{3, -.5}, {-.5, .5}};
k = {{4, -1}, {-1, 1}};
initu = u[0] == {{0}, {.1}};
initv = u'[0] == {{1}, {0}};
u[t_] := {{u1[t]}, {u2[t]}};
sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}},
initu, initv}, u[t], {t, 0, 100}]


Now M sees that u[t] is {{u1[t]}, {u2[t]}} otherwise it did not know that.

Or you can simplify things little:

m = {{2, 0}, {0, 1}};
c = {{3, -.5}, {-.5, .5}};
k = {{4, -1}, {-1, 1}};
initu = u[0] == {{0}, {.1}};
initv = u'[0] == {{1}, {0}};
u[t_] := {u1[t], u2[t]};
sol = First@NDSolve[{Thread[m.u''[t] + c.u'[t] + k.u[t] == {Sin[2 t], Sin[2 t]}],
initu, initv}, u[t], {t, 0, 100}];
Plot[{u1[t] /. sol, u2[t] /. sol}, {t, 0, 100}, PlotTheme -> "Detailed"]