How to solve ODE's in Matrix Form?

3 ビュー (過去 30 日間)
Benjamin Watson
Benjamin Watson 2019 年 2 月 26 日
コメント済み: Benjamin Watson 2019 年 2 月 27 日
Hi,
I have a set of equations like this and am clueless on how to solve on MATLAB and hope someone can help. The intial conditions are P0(0) = 1; P1(0) = 0.
MATLAB.PNG
  4 件のコメント
James Tursa
James Tursa 2019 年 2 月 26 日
Please post what you have tried and what problems you are having with your code and we can help.
Benjamin Watson
Benjamin Watson 2019 年 2 月 27 日
Hi James Tursa,
I've finally got it working using the dsolve function but is there anyway for it to solve in symbolically as I have Lam values and Mu values which I've had to input a numerical value for but is there anyway to keep these in sysmbolic form. Also is there anyway to get an output which limits t to infinty? Thanks Ben
syms P0(t) P1(t)
Lam = 2000
Mu = 1000
eqns = [diff(P0,t) == -Lam*P0+Mu*P1,...
diff(P1,t) == Lam*P0-Mu*P1];
sol = dsolve(eqns, P0(0) == 1, P1(0) == 0)
solP0(t)= sol.P0
solP1(t)= sol.P1

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2019 年 2 月 26 日
For a linear system such as yours, another option is the expm (link) function. It is the term in the solution for a linear system:
where = expm(A*t).
This requires a loop for the inputs and for values of ‘t’, however that is more of an inconvenience than a problem.

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by