How to solve differential equations involving matrices?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Bjorn Gustavsson
on 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 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!