I would drop the [t]
from v[t]
in the requested form of the solution, and possibly use NDSolveValue
, depending on how I wanted to use the solution.
sol = First@NDSolve[DE, v, {t, 0, 10}] (* returns a rule v -> InterpolatingFunction[..] *)
vIF = NDSolveValue[DE, v, {t, 0, 10}] (* return an InterpolatingFunction[..] *)
Then you can evaluate v
like this:
v[4] /. sol
(* 225.484 *)
vIF[4]
(* 225.484 *)
To get a table of the actual steps taken by NDSolve
, you can take advantage of built-in methods of InterpolatingFunctions
that allow you some access to the internal data:
vIF@"Methods"
(*
{"Coordinates", "DerivativeOrder", "Domain", "ElementMesh",
"Evaluate", "GetPolynomial", "Grid", "InterpolationMethod",
"InterpolationOrder", "MethodInformation", "Methods",
"OutputDimensions", "Periodicity", "PlottableQ", "Properties",
"QuantityUnits", "Unpack", "ValuesOnGrid"}
*)
The following returns a table of {t, v}
steps:
soltab = Transpose@{Flatten@vIF@"Grid", vIF@"ValuesOnGrid"};
The following returns a table of {t, v, v'}
including the values of the derivative v'
, in case you want to use the table to do Hermite interpolation in another application:
soltab = Transpose@{Flatten@vIF@"Grid", vIF@"ValuesOnGrid", vIF'@"ValuesOnGrid"};
But if you want an equal-step table, you can use Table
and either sol
or vIF
:
soltab = Table[{t, v[t] /. sol}, {t, 0., 10.}]
soltab = Table[{t, vIF[t]}, {t, 0., 10.}]
The tables can be exported as Bill Nelson shows:
Export["file.csv", soltab]