Example 13
Mass-Spring system with NDSolve
GIVEN: two masses and three springs (x,y,z)
REQUIRED: find and plot displacements vs. time
SOLUTION:Generate example13.nb
num = 3
vars = Table[x[i][t], {i, num}]
m = {{-20, 10, 0}, {10, -20, 10}, {0, 10, -20}}
rightside = m . vars
equations = Table[x[i]''[t] == rightside[[i]], {i, num}]
initdata = {x[1][0] == 0, x[2][0] == 0, x[3][0] == 1,
x[1]'[0] ==1, x[2]'[0] == -1, x[3]'[0] == 2}
eqnsANDinit = Join[equations, initdata];
solution = NDSolve[eqnsANDinit, vars, {t, 0, 3}]
Plot[Evaluate[Table[x[i][t] /.solution, {i, num}]], {t, 0, 3}]
Example
Homework:
Change the initial conditions
Please send questions or suggestions about this web page to beatnic@aset.psu.edu
ASET | ITS | Penn State
|