Is it possible to attach certain pieces of code to certain controls in a Manipulate? For example, consider the following Manipulate
Manipulate[
data = Table[function[x], {x, -Pi*10, Pi*10, Pi/1000}];
ListPlot[{x, data}, PlotRange -> {{start, stop}, Automatic}]
, {function, {Sin, Cos, Tan}}
, {start, 1, Length[data]}
, {{stop, 300}, 1, Length[data]}
]
Generation of the data is expensive but it only needs to be done if I change function. So, I'd like the line
data = Table[function[x], {x, -Pi*10, Pi*10, Pi/1000}];
to only run when I change the function control...i.e. I want to attach that line of code to the 'function' control. As it stands, the data is generated when I move the plot range too which is not what I want.
Manipulate
or are you fine with aDynamicModule
? One option forManipulate
is to memoize it... $\endgroup$