Solving system of differential equations using loops

I have $F$ system of differential equations. Out of those $F$ equations except for first and last I have general form for the remaining equations (say $dP_{i}/dt)$. Let $dP_0/dt,dP_F/dt$ denotes the 1st and last equations respectively. Now I would like to solve them for varies values of $F$. i,e, If F=3, I will have only three equations in which $dP_1/dt$ I will get from general form $dP_i/dt$ by putting i=1, Similarly for other values F's. Can some one help me out solve this for different values of $F$ using for, while loops.

Edit: I tried in following way.

node[0,F] = p[0]'[t] == first eqn ;
node[i,F] = p[i]'[t] == i^{th} eqn ;
node[F,F] = p[F]'[t] == F^{th}eqn;


for example for F=4

system = Table[node[i, F], {i, 1, 3}, {F, 4, 4}]


(I am missing first and last equation in table, I don't know how include them) Then I am thinking to use NDSolve[system] but I don't know exact syntax for this. Each of equation have different initial conditions also.

Thanks.

• If you are unable to understand or need more information please let me know. Oct 28, 2014 at 5:43
• If you would add some Mathematica code (e.g. for your equations and for what you have tried for the loops) it will be easier for others to help. Oct 28, 2014 at 5:49
• @Karsten 7 I have added some extra details, Thanks Oct 28, 2014 at 6:46
• Please edit your question to include the Mathematica code you are working on. Only good questions are likely to get great answers. See the editing help for proper formatting. Oct 28, 2014 at 9:13
• I edited your code this time. Please learn how to format your post by following the links provided by @rhermans above. Thanks Oct 28, 2014 at 13:14

I'm not clear on all the details of your problem, but here is a general setup:

system = Table[node[i, F], {i, 0, F}]; (* equations *)
initialvalues = {p0, p1, ... (* fill in as appropriate with actual numbers *)};
initialcondition = Table[p[i][0] == initialvalues[[i+1]], {i, 0, F}];
funcs = Table[p[i], {i, 0, F}];  (* functions to solve for *)
sol =
NDSolve[{system, initialcondition}, funcs, {t, t1, t2}] (* return solution for t1 <= t <= t2 *)


The initial values and the time interval were not specified in the question, so I leave them for you to fill in. The list initialvalues needs to contain F + 1 numbers. Since Mathematica indices always begin with 1, the index i will be one off the Part number. Also, the times t1 and t2 need to be definite numbers.

DSolve might be used in place of NDSolve if the system can be integrated symbolically. In that case the last argument is usually just t.