2
$\begingroup$

I have a problem in solving a type of ODE from NDSolve. Specifically I want to know the solution at time T (say T=50). The number of differential equations increases at each iteration. This equations involves one parameters, and I want the solution of the differential equations at each iteration.

T = 10;
nu = 0.2;
n = 5;

vars = Table[Subscript[x, j][t], {i, n}, {j, i}];

eqns = Table[{
    Subscript[x, j]'[t] == Subscript[x, j][t] (1 - Subscript[x, j][t] - nu Sum[Subscript[x, k][t] Boole[k != j], {k, i}]),
    Subscript[x, j][0] == 0.3},
  {i, n}, {j, i}
 ];

The variable eqns gives exactly the process of iteration that I need

sol = NDSolve[eqns, Table[Subscript[x, j], {i, n}, {j, i}], {t, 0, T}, DependentVariables -> vars]

But Mathematica gives the message

NDSolve::ndode: Input is not an ordinary differential equation. >>

I don't understand how to fix it. I believe it violates some operation NDSolve.

$\endgroup$
2
  • $\begingroup$ It is not clear to me what you are trying to do, but I can say with reasonable confidence that your NDSolve arguments are invalid. I recommend that you state clearly the problem you are trying to solve. $\endgroup$
    – bbgodfrey
    Commented Aug 19, 2016 at 3:55
  • $\begingroup$ The sentence "The number of differential equations increases at each iteration" isn't clear. Do you want to increase n at some point? $\endgroup$
    – Chris K
    Commented Aug 19, 2016 at 18:24

1 Answer 1

0
$\begingroup$

If you are attempting to solve ODEs one through five in sequence, one way to do so is

GraphicsGrid[{Table[s = NDSolve[eqns[[n]], vars[[n]], {t, 0, T}];
    Plot[Evaluate[vars[[n]] /. s], {t, 0, T}, PlotRange -> All], {n, 5}]}, 
    ImageSize -> Large]

enter image description here

Alternatively, the solutions can be presented in a single plot.

Show @@ Table[s = NDSolve[eqns[[n]], vars[[n]], {t, 0, T}];
    Plot[Evaluate[vars[[n]] /. s], {t, 0, T}, PlotRange -> All], {n, 5}]

enter image description here

Not surprisingly, all curves for each value of n coincide.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.