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