jatorre
- 3
- 0
Hello everyone.
This is my first post after looking for information about a simple question. Unfortunately I didn't found information in any other posts in this forum so, here we go!
I'm trying to solve numerically a set of N ODEs with Mathematica 7.0. Let me call x(t) an array of N elements and M a NxN matrix. I would like to solve the problem dx/dt = - M x.
So I firstly define the array:
with a "pseudo" Dirac Delta initial condition:
This system can be solved with NDSolve:
If I plot the solution I can check the correct answer:
And here comes my question. How to obtain a specific value of xi (e.g., xi[1,0.1])?
I tried to do it using directly
but the answer was simply
. Using Flatten I obtain the same result (without the braces) and if I try with
I obtain an array of elements xi[i,0.1] with i=1,N.
At this point I have no idea of how to deal with this. I am quite sure that this has to be a silly question but, as far as I know, I cannot obtain the correct answer.
Thank you very much in advanced and my apologies if this is a duplicated question.
Arturo.
This is my first post after looking for information about a simple question. Unfortunately I didn't found information in any other posts in this forum so, here we go!
I'm trying to solve numerically a set of N ODEs with Mathematica 7.0. Let me call x(t) an array of N elements and M a NxN matrix. I would like to solve the problem dx/dt = - M x.
So I firstly define the array:
Code:
X[t_] = Table[xi[i, t], {i, N}];
with a "pseudo" Dirac Delta initial condition:
Code:
X0 = SparseArray[Table[{i} -> 0, {i, N}]];
X0[[N/2]] = 1;
This system can be solved with NDSolve:
Code:
eqns = Thread /@ {X'[t] == -M.X[t], X[0] == X0};
sol = NDSolve[eqns, X[t], {t, 0, 1}];
If I plot the solution I can check the correct answer:
Code:
Plot[Evaluate[Table[xi[i, t] /. sol, {i, N}]], {t, 0, 1}]
And here comes my question. How to obtain a specific value of xi (e.g., xi[1,0.1])?
I tried to do it using directly
Code:
xi[1, 0.1] /. sol
Code:
{xi[1, 0.1]}
Code:
X[0.1]/.sol
At this point I have no idea of how to deal with this. I am quite sure that this has to be a silly question but, as far as I know, I cannot obtain the correct answer.
Thank you very much in advanced and my apologies if this is a duplicated question.
Arturo.