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?

回答 (1 件)

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;
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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by