Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Varying a constant in an ODE to Manipulate solution
Replies: 10   Last Post: Jul 2, 2012 5:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 695
Registered: 10/29/11
Re: Varying a constant in an ODE to Manipulate solution
Posted: Jun 14, 2012 5:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

sol[c_] := {x[t], y[t], z[t]} /. First[
NDSolve[{y''[t] + Sin[y[t]/c] == 0,
y'[0] == 0, y[0] == 1/(1 + c),
x'[t] == t, x[0] == c^2,
z'[t] == 2 c x[t] - y[t], z[0] == 2},
{x, y, z}, {t, -3, 3}]]

Use a single Evaluate. For example,

Manipulate[
Plot[Evaluate[{sol[c][[1]], sol[c][[2]]}], {t, -3, 3},
PlotStyle -> {Green, Thick},
ImageSize -> 200,
AspectRatio -> Automatic,
PlotRange -> {{-3, 3}, {-1.05, 8.05}}],
{c, -0.5, 2, 0.2}]

Manipulate[
Plot[Evaluate[Most[sol[c]]], {t, -3, 3},
PlotStyle -> {Green, Thick},
ImageSize -> 200,
AspectRatio -> Automatic,
PlotRange -> {{-3, 3}, {-1.05, 8.05}}],
{c, -0.5, 2, 0.2}]

Manipulate[
Plot[Evaluate[Rest[sol[c]]], {t, -3, 3},
PlotStyle -> {Green, Thick},
ImageSize -> 200,
AspectRatio -> Automatic,
PlotRange -> {{-3, 3}, {-10, 10}}],
{c, -0.5, 2, 0.2}]

Manipulate[
Plot[Evaluate[Drop[sol[c], {2}]], {t, -3, 3},
PlotStyle -> {Green, Thick},
ImageSize -> 200,
AspectRatio -> Automatic,
PlotRange -> {{-3, 3}, {-10, 10}}],
{c, -0.5, 2, 0.2}]


Bob Hanlon


On Wed, Jun 13, 2012 at 4:57 AM, Narasimham <mathma18@hotmail.com> wrote:
> Same topic is continued. Thanks to Murray Eisenberg and Bob Hanlon
>
> All variables or a single variable are easily pocked out from sol[c_]
> list for plotting.
> But how to pick out two out of them for ParametricPlot ( 2D) ?
>
> sol[c_] := {x[t], y[t], z[t]} /.
> First[NDSolve[{y''[t] + Sin[y[t]/c] == 0, y'[0] == 0,
> y[0] == 1/(1 + c), x'[t] == t, x[0] == c^2,
> z'[t] == 2 c x[t] - y[t], z[0] == 2}, {x, y, z}, {t, -3, =

3}]]
> Manipulate[
> Plot[Evaluate[sol[c]], {t, -3, 3}, PlotStyle -> {Red, Thick},
> AspectRatio -> Automatic,
> PlotRange -> {{-3, 3}, {-10, 10}}], {c, -0.5, 2, 0.2}]
> Manipulate[
> Plot[Evaluate[sol[c][[1]]], {t, -3, 3}, PlotStyle -> {Red, Thick},
> AspectRatio -> Automatic,
> PlotRange -> {{-3, 3}, {-10, 10}}], {c, -0.5, 2, 0.2}]
> " 2 parameter Dynamic manipulation not OK "
> Manipulate[
> Plot[{Evaluate[sol[c][[1]]], Evaluate[sol[c][[1]]]}, {t, -3, 3},
> PlotStyle -> {Green, Thick}, AspectRatio -> Automatic,
> PlotRange -> {{-3, 3}, {-10, 10}}], {c, -0.5, 2, 0.2}]
>
> Regards
> Narasimham
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.