       NDSolve, Loop, Table, Plot

• To: mathgroup at smc.vnet.net
• Subject: [mg77583] NDSolve, Loop, Table, Plot
• From: Solver <shawnleroux at hotmail.com>
• Date: Wed, 13 Jun 2007 07:35:30 -0400 (EDT)

```Hi,

I have a system of 3 differential equations and I would like to
numerically solve them for different values of one parameter (e.g., p1
= 0.5, 0.6, 0.7, 0.8, etc). Then, I want to 1) make a table for the
results of B0, B1, and B2 for all values of p1 and 2)
make plots of B0, B1, B2 through time for the different values of p1.
Below is the code I tried. The table seems to work sometimes but when
I run the code multiple times, the output is the same for all values
of p1 (i.e., {{3.99315, 3.99315, 3.99315, 3.99315, 3.99315, 3.99315},
{
0.0813405, 0.0813405, 0.0813405, 0.0813405, 0.0813405,
0.0813405}, {0.021349, 0.021349, 0.021349, 0.021349, 0.021349,
0.021349}}. I don't understand why?
The Plot function gives me multiple plots but they are always the
same, so it is not drawing plots for the different values of p1.

J = 1;
r0 = 0.2;
r1 = 0.2;
r2 = 0.2;
p1 = 0.1;

dB0 = J - r0*B0[t] - B0[t]*B1[t];
dB1 = p1*B0[t]*B1[t] - r1*B1[t] - B1[t]*B2[t];
dB2 = p2*B1[t]*B2[t] - r2*B2[t];

A = Flatten[Map[({B0, B1, B2} /. # ) &,
sol = Table[NDSolve[{B0'[t] == dB0, B1'[t] == dB1, B2'[t] == dB2,
B0 == 1, B1 == 1, B2 == 1}, {B0, B1, B2},
{t, 0, 200}], {p1, 0.5, 1, 0.1}]], 1] // Transpose
Export["A.csv", A];
Do[Plot[Evaluate[{B0[t], B1[t], B2[t]} /. sol, {t, 0, 200}, PlotStyle -
>
{{RGBColor[1, 0, 0]}, {RGBColor[0, 1, 0]}, {RGBColor[0, 0, 1]}}]],
{p1, 0.5, 1, 0.1}]

Thanks!

```

• Prev by Date: Re: Normally Distributed Random Matrix
• Next by Date: Re: v6: still no multiple undo?
• Previous by thread: Re: Integral that Mathematica 5.1 can do and Mathematica 6 cannot do
• Next by thread: Re: NDSolve, Loop, Table, Plot