How to solve differential equations involving matrices?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to solve the differential equation below.
E11 through E44 are all functions of some combination of P11 through P44.
How can I solve this in MATLAB?
0 Kommentare
Antworten (1)
Bjorn Gustavsson
am 28 Apr. 2021
Based off of your description I see no difference betwee solving these 4 x 4 coupled ODEs and solving them as 16 x 1 coupled ODEs. Using that you can simply rearrange your components in a format matlab's ODE-integrating functions expect. Something like this:
function dPdt = ode4by4as16by1(t,P,Perhaps_pars)
p1 = Perhaps_pars(1); % If you need some parameters
p2 = Perhaps_pars(2); % that you might want to tune between different runs...
E11 = E11fcn(t,P,p1); % possibly you prefer E11fcn(t,reshape(P,[4,4],p1)
E21 = E21fcn(t,P,p2);
% etc
dPdt = [E11;
E21;
E31;
% etc
E44];
end
This should be possible to integrate with ode45:
P0 = randn(4,4);
t_span = [0,exp(pi)];
[t,P] = ode45(@(t,P,[log(2),2^.5]),t_span,P0(:));
HTH
0 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!