# Plotting data from a Table in Mathematica

I have been able to solve some differential equations using Tables. The code works fine without errors. However, I am unable to plot the results. Any help would be appreciated.

n = 10;
initialx = Table[Subscript[x, i][0] == (i - 1)*0.1, {i, 1, 11}];
initialy = Table[Subscript[y, i][0] == 0, {i, 1, 11}];

eqnvx = Table[
Subscript[x, i]'[t] == (100*Subscript[x, i][t]), {i, 2, 10} ];
eqnvx1 = {Subscript[x, 1]'[t] == 0};
eqnvx11 = {Subscript[x, 11]'[t] == 0};

eqnvy = Table[
Subscript[y, i]'[t] == (100*Subscript[y, i][t]), {i, 2, 10} ];
eqnvy1 = {Subscript[y, 1]'[t] == 0};
eqnvy11 = {Subscript[y, 11]'[t] == 0};

s = NDSolve[{eqnvx1 && eqnvx && eqnvx11 && eqnvy1 && eqnvy && eqnvy11,
initialx && initialy}, {Subscript[x, i], Subscript[y, i]}, {t, 0,
20}]
Plot[Evaluate[Subscript[x, 1][t] /. s], {t, 0, 100}]

• what makes you say the code works fine? Lack of error messages does not in itself mean the code is working. It does not work for me with 10.3 on Mac – Mike Honeychurch Dec 1 '15 at 21:46
• – Dr. belisarius Dec 1 '15 at 21:46
• Well, by working fine I meant there are no errors, so I cant know where the problem is. I have to use subscripted symbols otherwise I would need to write 22 equations. – Alpha Centaur Dec 1 '15 at 21:50
• Use, for instance, x[i] instead of Subscript[x, i]. Subscripts work funny in Mathematica. You should follow the link posted by @belisariushassettled and read it. – march Dec 1 '15 at 21:55
• you can use x[1][t] .. – george2079 Dec 1 '15 at 21:59

your fundamental problem is the variable list:

    ...  {Subscript[x, i], Subscript[y, i]} ..


mathematica does not understand that you meant "for all i", you need to explicitly list:

     NDSolve[ .. ,Flatten[Table[{Subscript[x, i], Subscript[y, i]}, {i, 11}]], {t,0,20} ]


I'm not a fan of using Subscript but it does work in this case.

With that change you get a result.. ( note x1[t] comes out zero, but some others are not all zero )

• thanks @george2079 , this solves my problem :) – Alpha Centaur Dec 1 '15 at 22:11
• I am normally a MATLAB user, and this is my first exposure to Mathematica ... actually, I am impressed with the subscripts, specially because in newer versions of Mathematica they display like actual subscripts ... – Alpha Centaur Dec 3 '15 at 16:37
• need your help with one more thing please ... i want to plot (x,y) data for the full range of time ... how can it be done using Table ? thanks ! – Alpha Centaur Dec 8 '15 at 9:02