필터 지우기
필터 지우기

ode45

조회 수: 7 (최근 30일)
Nani C
Nani C 2012년 5월 7일
Hi, Having solved a second order equation of motion using ode45 function i wonder how could i modify the function to solve a whole system of equations in matrix form [A]{xdoubledot}+[B]{xdot}+[c]{x}={p(t)}, instead of solving individual equations for x vector variables. Would that be possible ?

채택된 답변

Richard Brown
Richard Brown 2012년 5월 7일
Yes, certainly possible. The basic approach would be to turn it into a system of first order odes of twice the dimension as follows (where x and xdot are vectors):
y1 = x
y2 = xdot
then, if A is invertible
y1' = y2
y2' = A \ (-B*y2 - c*y1 + p(t))
You'd then write a file to implement this in MATLAB like this
function dy = myode(t, y)
n = numel(y)/2;
y1 = y(1:n);
y2 = y(n+1:2*n);
dy = [y2; A \ (-B*y2 - c*y1 + p(t))
end
and solve it with ode45 (or whichever solver happens to be most suitable) as usual.
  댓글 수: 2
Nani C
Nani C 2012년 5월 7일
t.y. Richard. it worked. It would be helpful if you can clarify on 'twice the dimension'. Any help links will also be useful.
Jan
Jan 2012년 5월 7일
You can convert an ODE of degree 2 for an n-dimensional vector to an ODE of degree 1 for a 2n-dimensional vector. This means "twice the dimensions". In other words: Instead of calculating the 1st and 2nd derivative of the position, you calculate the 1st derivative of the position and the velocity.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by