# How do get an output table or a plot of individual variables from NDSolve output

I have the following equations and settings:

Clear[koff]; koff = 5.*10^-5;
Clear[kon]; kon = 1.*10^4;
Clear[koff2]; koff2 = 1.*10^-5;
Clear[kon2]; kon2 = 1.*10^4;
Clear[kcg]; kcg = 1.2*10^-5;
Clear[ndsolKRH];
ndsolKRH =
NDSolve[{
D[ag[t], t] == -kon2*ag[t]*b[t] + koff2*cg[t] - kcg ag[t],
D[a[t], t] == -kon*a[t]*b[t] + koff*c[t],
D[cg[t], t] == kon2*ag[t]*b[t] - koff2*cg[t],
D[c[t], t] == kon*a[t]*b[t] - koff*c[t],
D[b[t], t] == -kon2*ag[t]*b[t] - kon*a[t]*b[t] + koff2*cg[t] + koff*c[t],
ag == 450. 10^-9, a == 90.247 10^-9, cg == 0,
c == 473.75 10^-9, b == 26.25 10^-9},
{ag, a, b, c, cg},
{t, 0, 1200000}][];


I would like to get a table of individual numbers for cg and ag. I would also lime to be able to plot these variables vs time. At present I can do it one at a time but there must be a lot easier way.

I am doing the following:

Clear[solKRHfix]; solKRHfix = ag /. ndsolKRH;


AND THEN:

solKRHfix

• Fixed formatting, but didn't spend any time working out what the unrecognized symbols are. Please check my edit and modify as needed. – bobthechemist Aug 2 '14 at 16:32

Assuming that I interpreted the input correctly,

koff = 5. 10^-5;
kon = 1. 10^4;
koff2 = 1. 10^-5;
kon2 = 1. 10^4;
kcg = 1.2 10^-5;

ndsolKRH = NDSolve[{
ag'[t] == -kon2*ag[t]*b[t] + koff2*cg[t] - kcg ag[t],
a'[t] == -kon*a[t]*b[t] + koff*c[t],
cg'[t] == kon2*ag[t]*b[t] - koff2*cg[t],
c'[t] == kon*a[t]*b[t] - koff*c[t],
b'[t] == -kon2*ag[t]*b[t] - kon*a[t]*b[t] + koff2*cg[t] + koff*c[t],
ag == 450. 10^-9,
a == 90.247 10^-9,
cg == 0,
c == 473.75 10^-9,
b == 26.25 10^-9},
{ag, a, b, c, cg},
{t, 0, 200000}][];

Plot[(# /. ndsolKRH)[t], {t, 0, 200000},
Frame -> True,
Axes -> False,
FrameLabel -> {t, ToString[#] <> "[t]"},
ImageSize -> 300] & /@
{ag, a, b, c, cg} // Column TableForm[
Table[(func /. ndsolKRH)[t],
{t, 0, 200000, 20000},
{func, {ag, a, b, c, cg}}],
Range[0, 200000, 20000],
(ToString[#] <> "[t]") & /@ {ag, a, b, c, cg}}] Clear[koff]; koff = 5.*10^-5;
Clear[kon]; kon = 1.*10^4;
Clear[koff2]; koff2 = 1.*10^-5;
Clear[kon2]; kon2 = 1.*10^4;
Clear[kcg]; kcg = 1.2*10^-5;
Clear[ndsolKRH];
ndsolKRH =
NDSolve[{
D[ag[t], t] == -kon2*ag[t]*b[t] + koff2*cg[t] - kcg ag[t],
D[a[t], t] == -kon*a[t]*b[t] + koff*c[t],
D[cg[t], t] == kon2*ag[t]*b[t] - koff2*cg[t],
D[c[t], t] == kon*a[t]*b[t] - koff*c[t],
D[b[t], t] == -kon2*ag[t]*b[t] - kon*a[t]*b[t] + koff2*cg[t] + koff*c[t],
ag == 450. 10^-9, a == 90.247 10^-9, cg == 0,
c == 473.75 10^-9, b == 26.25 10^-9},
{ag, a, b, c, cg},
{t, 0, 1200000}][];

{ag, a, b, c, cg} = ndsolKRH[[All, 2]];

tbl = Table[Through[{ag, a, b, c, cg}[t]], {t, 0, 1200000, 100000}]; Plot[Evaluate@Through[{ag, a, b, c, cg}[t]], {t, 0, 1200000}] 