フィルターのクリア

How to solve a system of differential equations without symbolic math lab

11 ビュー (過去 30 日間)
Anna
Anna 2019 年 11 月 8 日
コメント済み: Walter Roberson 2019 年 11 月 8 日
I have three equations that are similar to these,
a, b, c, d, and e are all known and I have initial conditions for X, Y, and Z. I have equations saved in their own functions like this:
function dX = fun_dX(a,b,c,d,X,Y)
dX = a*X*(1-b*X)-c*X*Y-d
end
What functions/code should I be using to solve the system without the use of symbolic math lab? Also, how do I get it in a form that I can plot my answers all on one graph (using hold on)? I tried ode45 to solve them individually (for example solving the first equation with a given Y) but I believe the use of ode45 was wrong because the graph of X vs. t did not make sense.

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 11 月 8 日
a = whatever; b = whatever; c = whatever; d = whatever; e = whatever;
[t, xyz] = ode45(@(t, XYZ) odefun(t, XYZ, a, b, c, d, e), tspan, xyz0);
plot(t, xyz);
function dXYZ = odefun(t, XYZ, a, b, c, d, e)
X = XYZ(1); Y = XYZ(2); Z = XYZ(3);
dXYZ(1) = a*X*(1-b*X) - c*X*Y - d;
dXYZ(2) = a + b*Y - d*X.^2*Y - c*X*Y;
dXYZ(3) = e*Z + b^2*Z - c*Z*X _ d*Y*Z;
end
  5 件のコメント
Anna
Anna 2019 年 11 月 8 日
What do you mean by that? I've tried changing xyz0 but it hasn't gotten rid of the errors.
Walter Roberson
Walter Roberson 2019 年 11 月 8 日
function dXYZ = odefun(t, XYZ, a, b, c, d, e)
X = XYZ(1); Y = XYZ(2); Z = XYZ(3);
dXYZ(1,1) = a.*X.*(1-b.*X) - c.*X.*Y - d;
dXYZ(2,1) = a + b.*Y - d.*X.^2.*Y - c.*X.*Y;
dXYZ(3,1) = e.*Z + b.^2.*Z - c.*Z.*X + d.*Y.*Z;
end

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

カテゴリ

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