Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Manipulate with non-explicit variables' topicStudent Support Forum > General > Archives > "Manipulate with non-explicit variables"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
yehuda
01/13/13 05:59am

Why would you need this rule anyway?
You can use endval directly as it is use in Table (in place of Manipulate)

Manipulate[
sol = NDSolve[{y''[x] + Sin[y[x]] y[x] == 0, y[0] == 1, y'[0] == 0},
y, {x, 0, endval}][[1]];
Plot[Evaluate[y[x] /. sol], {x, 0, endval}], {endval, 10, 20}]

if you insist of using rules you need to be careful enough to evaluate all Plot arguments that depend on this rule due to the HoldAll attribute of Plot (in this case ignore the "error" mark of Plot
Manipulate[
myrule = end -> endval;
sol = NDSolve[{y''[x] + Sin[y[x]] y[x] == 0, y[0] == 1, y'[0] == 0},
y, {x, 0, end} /. myrule][[1]];
Plot[Evaluate[y[x] /. sol, {x, 0, end} /. myrule]], {endval, 10, 20}]

or use two Evaluate calls

Manipulate[
myrule = end -> endval;
sol = NDSolve[{y''[x] + Sin[y[x]] y[x] == 0, y[0] == 1, y'[0] == 0},
y, {x, 0, end} /. myrule][[1]];
Plot[Evaluate[y[x] /. sol],
Evaluate[{x, 0, end} /. myrule]], {endval, 10, 20}]


yehuda



URL: ,

Subject (listing for 'Manipulate with non-explicit variables')
Author Date Posted
Manipulate with non-explicit variables Abed Alnaif 01/11/13 6:05pm
Re: Manipulate with non-explicit variables Michael 01/12/13 9:09pm
Re: Manipulate with non-explicit variables yehuda 01/13/13 05:59am
< Previous CommentHelp | Reply To Comment | Reply To Topic