Matrix System of ODEs

조회 수: 3 (최근 30일)
Paul
Paul 2013년 10월 12일
답변: Paul 2013년 10월 12일
Hello Forum.
I'm not sure how the following works with matlab. Imagine I have a set of coupled ODEs defined by the following (n x 1) vector:
beta' = K0 beta + beta' H0 beta
where K0 is a (n x 1) and H0 is (n x n). Some of the elements of beta can be solved in closed form and so I have explicit solutions while the rest need to be solved numerically. I'm unsure where to begin in terms of using ODE45 or the like in terms of coding these equations. For example, is it possible to write a function inside one of the elements of beta? For example, if I know the solution to beta_3 ?
Obviously I could just multiple this out line by line but this is somewhat inefficient and prone to mistakes. I guess my question really relates to vectorizing ODE systems. Any pointers would be greatly appreciated.
Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2013년 10월 12일
I suspect something like this:
function r = my_ode_fun(t, y)
full_y = zeros(n, 1);
full_y([1 2 5 7 8 9]) = y; %copy in the elements that need numeric solutions
full_y(3) = ..... %compute the elements that can be done in closed form
full_r = K0 * full_y + full_y' * H0 * full_y; %guessing that the beta' on the left means differentiation but the one on the right is transpose
r = full_r([1 2 5 7 8 9]); %select back down to the ones that need to be propagated forward

추가 답변 (1개)

Paul
Paul 2013년 10월 12일
Yes , you guessed correct on the primes.
Thanks a lot. Actually a lot simpler than I was thinking.

카테고리

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