Matrix System of ODEs

3 visualizaciones (últimos 30 días)
Paul
Paul el 12 de Oct. de 2013
Respondida: Paul el 12 de Oct. de 2013
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Oct. de 2013
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

Más respuestas (1)

Paul
Paul el 12 de Oct. de 2013
Yes , you guessed correct on the primes.
Thanks a lot. Actually a lot simpler than I was thinking.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by