Skip to main content
Fixed formatting
Source Link
Öskå
  • 8.6k
  • 4
  • 33
  • 53

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.

In[10]:= 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]}};

In[16]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

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}] 

Out[16]= {{u -> u}}

{{u -> u}} 

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

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

Out[17]= {{u -> u}}

{{u -> u}} 

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.

In[10]:= 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]}};

In[16]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

Out[16]= {{u -> u}}

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

Out[17]= {{u -> u}}

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}} 
deleted 655 characters in body
Source Link
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]}}; 

In[10]:= 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]}};

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

In[16]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}] 

Out[16]= {{u -> u}}

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^′′)[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^′)[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

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

NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^′′)[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

Out[17]= {{u -> u}}

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]}}; 

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}] 

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^′′)[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^′)[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^′′)[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

In[10]:= 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]}};

In[16]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

Out[16]= {{u -> u}}

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

Out[17]= {{u -> u}}

Fixed formatting
Source Link
Öskå
  • 8.6k
  • 4
  • 33
  • 53

I'll preface this with the fact that I have no idea what I'm doing. I'm new to MathematicaMathematica, I've only used it to solve simple ODEs with NDsolveNDsolve. 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.

In[381]:= 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]}};

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]}}; 

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

In[387]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}] 

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^[Prime][Prime])[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^[Prime])[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^′′)[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^′)[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

Out[387]= NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^[Prime][Prime])[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^′′)[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

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.

In[381]:= 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]}};

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

In[387]:= sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}]

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^[Prime][Prime])[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^[Prime])[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

Out[387]= NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^[Prime][Prime])[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

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]}}; 

During evaluation of In[381]:= SetDelayed::write: Tag List in {{u1},{u2}}[t_] is Protected. >>

sol = NDSolve[{m.u''[t] + c.u'[t] + k.u[t] == {{Sin[2 t]}, {Sin[2 t]}}, initu, initv}, u, {t, 0, 100}] 

During evaluation of In[387]:= NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {{{2,0},{0,1}}.({{u1},{u2}}^′′)[t]+{{3,-0.5},{-0.5,0.5}}.({{u1},{u2}}^′)[t]+{{4,-1},{-1,1}}.{{u1},{u2}}[t]=={{Sin[2 t]},{Sin[2 t]}},{{u1},{u2}}[0]=={{0},{0.1}},True}. >>

NDSolve[{{{2, 0}, {0, 1}}.({{u1}, {u2}}^′′)[ t] + {{3, -0.5}, {-0.5, 0.5}}.Derivative[1][{{u1}, {u2}}][ t] + {{4, -1}, {-1, 1}}.{{u1}, {u2}}[t] == {{Sin[2 t]}, {Sin[ 2 t]}}, {{u1}, {u2}}[0] == {{0}, {0.1}}, True}, {{u1}, {u2}}, {t, 0, 100}]

Source Link
Loading