我正在尝试解决由变量eqn1和eqn2给出的微分方程组。
lambda1 = 3;
lambda2 = 2;
gamma1 = 1;
gamma2 = 1;
delta1 = 1;
delta2 = 1;
syms n1(t) n2(t)
eqn1 = diff(n1) == (lambda1 - gamma1)*n1 - delta1*(n1 + n2)*n1;
eqn2 = diff(n2) == (lambda2 - gamma2)*n2 - delta1*(n1 + n2)*n2;
c1 = n1(0) == 10;
c2 = n2(0) == 10;
[a, b] = dsolve(eqn1, eqn2, c1, c2)
如果我没有指定条件c1和c2并且只运行:
[a, b] = dsolve(eqn1, eqn2)
然后一切都很好,我得到了:
a =
(6*exp(2*t)*n1(0))/(3*exp(2*t)*n1(0) + 4*exp((3*t)/2)*n2(0) + 6)
b =
(6*exp(t/2)*exp(t)*n2(0))/(3*exp(2*t)*n1(0) + 4*exp((3*t)/2)*n2(0) + 6)
但是当我尝试指定n1(0)和n2(0)时,正如您在源代码中看到的那样,我收到以下警告:
a =
Warning: The result cannot be displayed due a previously interrupted computation or out of memory. Run 'reset(symengine)' and rerun the commands to regenerate the result.
> In sym.disp at 36
In sym.display at 37
In competingForResources at 15
b =
[]
我无法绘制结果。我在那里错过了什么?如何以正确的方式指定条件,所以我得到了一个可绘制的结果?
答案 0 :(得分:1)
您可以使用subs
[a, b] = dsolve(eqn1, eqn2);
a=subs(a,'n1(0)',10);
a=subs(a,'n2(0)',10)
a =
(60*exp(2*t))/(30*exp(2*t) + 40*exp((3*t)/2) + 6)
与b