Matrix System of ODEs
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!