MATLAB Answers

How to solve differential equations involving matrices?

조회 수: 1(최근 30일)
Conner Eddy
Conner Eddy 2021년 4월 27일
답변: Bjorn Gustavsson 2021년 4월 28일
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?


Bjorn Gustavsson
Bjorn Gustavsson 2021년 4월 28일
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;
% etc
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(:));

Community Treasure Hunt

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

Start Hunting!

Translated by