# Plot the result of NDSolve as a RectangleChart3D?

Posted 1 year ago
1320 Views
|
4 Replies
|
0 Total Likes
|
 Hi, I request a solution to my problem where i want to plot the either the energy (x^2) or the signal itself (x) which is being the solution of a differential solution. I am successful only placing the phase-plane of a 2D system but the bar graph on the right does not shown anything. The code is splot = StreamPlot[{y, -Sin[x] - .25 y}, {x, -4, 4}, {y, -3, 3}]; Manipulate[ Grid[{{Show[splot, ParametricPlot[ Evaluate[ First[{x[t], y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]], {t, 0, T}, PlotStyle -> Red]], RectangleChart3D[{{0.25, 1, Evaluate[ First[{x[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]]}, {0.25, 1, Evaluate[ First[{y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]]}}, ChartLegends -> {"x[t]", "y[t]"}, PlotRange -> {0, 1}, ImageSize -> {200, 250}, ChartStyle -> {Red, Green}, AspectRatio -> 1, BarSpacing -> 0.2, Axes -> False]}}], {{T, 90}, 1, 100}, {{point, {2, 1.0}}, Locator}, SaveDefinitions -> True]  Attachments:
4 Replies
Sort By:
Posted 10 months ago
 Try this Manipulate[ Grid[{{Show[splot, ParametricPlot[ Evaluate[ First[{x[t], y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]], {t, 0, T}, PlotStyle -> Red]], RectangleChart3D[{{0.25, 1, #} & /@ Evaluate[ First[{x[t], y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]] /. t -> T]}, ChartLegends -> {"x[t]", "y[t]"}, PlotRange -> {0, 1}, ImageSize -> {200, 250}, ChartStyle -> {Red, Green}, AspectRatio -> 1, BarSpacing -> 0.2, Axes -> True]}}], {{T, 90}, 1, 100}, {{point, {2, 1.0}}, Locator}, SaveDefinitions -> True] because it's workingkeep in mind InterpolationFunction[] objects need an argument to show it's values, use mapping to avoid to solve the ODE more often than needed.
Posted 10 months ago
 I need a little more help in this...how is it possible?
 What did you try? This is Manipulate[ Grid[{{Show[splot, ParametricPlot[ Evaluate[ First[{x[t], y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]], {t, 0, T}, PlotStyle -> Red]], RectangleChart3D[{{0.25, 1, NIntegrate[ Dot[#, #] &[ Evaluate[ First[{x[t], y[t]} /. NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]] - .25 y[t], Thread[{x[0], y[0]} == point]}, {x, y}, {t, 0, T}]]] //. t -> q], {q, 0, T}]}}, ChartLegends -> {"E[T]"}, ImageSize -> {200, 250}, ChartStyle -> {Red}, AspectRatio -> 1, BarSpacing -> 0.2, Axes -> True]}}], {{T, 90}, 1, 100}, {{point, {2, 1.0}}, Locator}, SaveDefinitions -> True] and a picture is don't miss to skip the PlotRange -> {0,1} option.