If you don't have the Symbolic Toolbox, here is the procedure:
1) Write your equations in matrix form:
F*qdotdot + G*qdot + H*q + stuff = otherstuff
where q = [q1;q2], qdot = [q1dot;d2dot], qdotdot = [q1dotdot;q2dotdot]
F is a 2x2 matrix, G is a 2x2 matrix, H is a 2x2 matrix, stuff is a 2x1 vector, otherstuff is a 2x1 vector
2) Solve for the highest order derivatives:
qdotdot = F \ (otherstuff - G*qdot - H*q - stuff)
You don't need the explicit solution for qdotdot here ... you can leave it in the form above if you want.
3) Define first order equations by redefining variables:
y = [q1;q2;q1dot;q2dot]
so y(1) = q1, y(2) = q2, y(3) = q1dot, y(4) = q2dot
4) Rewrite all of your derivatives according to these new definitions:
ydot = [y(3);y(4);qdotdot]
where the qdotdot is replaced with the code in step (2) but using y(1), y(2), y(3), y(4) in place of q1, q2, q1dot, q2dot.
5) Code up step (4)
Use this as your function (handle) to feed to ode45( ).
댓글 수: 0
댓글을 달려면 로그인하십시오.