| 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: , |
|