Azzera filtri
Azzera filtri

Matrix System of ODEs

1 visualizzazione (ultimi 30 giorni)
Paul
Paul il 12 Ott 2013
Risposto: Paul il 12 Ott 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.

Risposta accettata

Walter Roberson
Walter Roberson il 12 Ott 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

Più risposte (1)

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

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by