Mathematica Asked on May 23, 2021
I have a 3-D data set (linked in the comment below) obtained via numerical integration. I would like to generate an interpolating function, and then use this function to numerically solve an ODE. For reference, the 3-D function looks like this:
The data set is used to create the interpolated function:
int = Interpolation[Flatten[Data1,1]]
I then sought to use NDSolve for the ODE xtraj'[T]==int[X,T]
, making the replacement X->xtraj[T]
. I then sought to solve the ODE for T=[-1,1]
for example. However I have not been successful in plotting the solution; using ParametricPlot
does not yield anything.
ode = {xtraj'[T] == int[X, T] /. {X -> xtraj[T]}, xtraj[-2] == -2}
trajectories = NDSolve[ode, xtraj[T], {T, -1, 1}]
ParametricPlot[trajectories, {T, -1, 1}]
Any help as to why the solution is not plotting, or fixes re: syntax errors or a better solution would be much appreciated.
Assuming rational expressions inside the data I first create usable data and interpolationfunction
data = Import["...data1.txt", "Table"] ;
xyz = Map[N[ToExpression[#]] &, data];
int = Interpolation[xyz]
Plot3D[int[x, y], {x, -2, 2}, {y, -2, 2},PlotRange->All]
The ode is
ode = {xtraj'[T] == int[xtraj[T], T], xtraj[-2] == -2}
Hope I understand trajectories
right
trajectories = NDSolveValue[ode, xtraj, {T, -2, 2}]
Plot[Evaluate[trajectories[T]], {T, -2, 2}]
Answered by Ulrich Neumann on May 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP