The following is a toy example that hopefully shows the problem clearly enough.
Why does the following code create a nice, manipulable output:
simulationOutput = {1337, 2337, 30, 3337};
Clear[tmax]
{irrelevantOutput1, irrelevantOutput2, tmax, irrelevantOutput3} = simulationOutput;
Manipulate[
Plot[t^2, {t, startTime, endTime}],
{startTime, Manipulator[Dynamic[startTime, (startTime = Min[tmax - 1, #];
endTime = Max[endTime, Min[# + 1, tmax]]) &], {0, tmax}] &},
{endTime, Manipulator[Dynamic[endTime, (endTime = Max[1, #];
startTime = Min[startTime, Max[0, # - 1]]) &], {0, tmax}] &},
Initialization :> ({startTime, endTime} = {0, 1})]
But this (almost identical) code, with the additional Block[],
simulationOutput = {1337, 2337, 30, 3337};
Clear[tmax]
Block[{irrelevantOutput1, irrelevantOutput2, tmax, irrelevantOutput3},
{irrelevantOutput1, irrelevantOutput2, tmax, irrelevantOutput3} = simulationOutput;
Manipulate[
Plot[t^2, {t, startTime, endTime}],
{startTime, Manipulator[Dynamic[startTime, (startTime = Min[tmax - 1, #];
endTime = Max[endTime, Min[# + 1, tmax]]) &], {0, tmax}] &},
{endTime, Manipulator[Dynamic[endTime, (endTime = Max[1, #];
startTime = Min[startTime, Max[0, # - 1]]) &], {0, tmax}] &},
Initialization :> ({startTime, endTime} = {0, 1})]]
result in this, un-manipulate-able output?
If you're interested, the background behind my question is as follows. I have a simulation of a system of oscillators. The behavior of this system is then studied by providing initial conditions, then using NDSolve to find the behavior from t=0
to t=tmax
. The output of the simulation (as simulationOutput
) is then fed into a function (of which the following is a simplified example) so that I can see the results - this is the reason why I'm limiting the range of times in which the startTime
and endTime
can vary in to keep the values in the range of the InterpolatingFunction
.