我正在试着解由变量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 =
[]
我无法绘制结果。我错过了什么?如何以正确的方式指定条件,从而得到可绘图的结果?
您可以直接使用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
相同