4
$\begingroup$

I have to solve $[m]x''+[c]x'+[k]x=[p]$ where x is function of $t$ after defining $[m],[c],[k]$ and $[p]$ in mathematica and x[t_]={x1[t],x2[t],x3[t]}

I am using NDSolve as

NDSolve[m.x''[t]+c.x'[t]+k.x[t]==p,x[t],{t,0,10}]

but I am not getting its solution even I tried

NDSolve[{m.x''[t]+c.x'[t]+k.x[t]==p,x[0]==0,x'[0]==0},x[t],{t,0,10}

can somebody help me to solve the initial equation?

$\endgroup$
3
  • 1
    $\begingroup$ You could take a look at 240947 for some hints on setting up a matrix differential equation. $\endgroup$
    – Tim Laska
    Jun 16, 2021 at 18:10
  • 2
    $\begingroup$ If 240947 does not answer your question, please edit your question to include the matrices in Mathematica format, so that readers can run your actual code. $\endgroup$
    – bbgodfrey
    Jun 16, 2021 at 18:37
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Jun 16, 2021 at 18:37

1 Answer 1

4
$\begingroup$

When dealing with matrix equations, I personally use Map[] to turn a matrix or a vector into a list of equations. Example below.

m = {{1, 2},{3, 4}};
c = {{5, 6},{7, 8}};
p = {1, 2};
x[t_] := {x1[t], x2[t]};

equation = m . x'[t] + c . x[t] - p;

NDSolve[
  Flatten[{
    Map[# == 0 &, equation],
    Map[# == 0 &, x[0]]
  }]
  , x[t], {t, 0, 10}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.