I’m using Manipulate[] to adjust several parameters, which will eventually generate some figures. After I get the desired view, I’d like to store the set of control parameters so that I can reuse them in the future.
Currently, I created two controls “recordControlParameters” and “userecordControlParameters” as flags, to let the code print out the list of control parameters as a list, and then paste their values to an assignment of these parameters at the beginning of the module, which could work, but the problem is, next time when I execute this code, I can no longer adjust any of these parameters if I turn on the “userecordControlParameters” mode.
I hope to find a way to be able to skip the assignment at the beginning of the code. For example, if I want to still adjust {b,c}, then I hope that, once I’m given this list at the beginning, I can skip the assignment of them.
The essense of this question is: given a list allvariables={a,b,c,d},variables2skip={b,d} and valueList={1,2,3,4}, with a,b,c,d already assigned to some nuemrical values by the control itself, how can we reassign a and c upon using allvariables and variables2skip and valueList?
Or is there any more elegant ways to cope with this?
Below is a minimal example (the real code has a large number of controls)
DynamicModule[{a, b, c, d, e, g, userecordedControlParameters,
recordControlParameters},
Manipulate[
Module[{},
If[userecordedControlParameters ==
1, {a, b, c, d} = {1, 2, 3, 0}];
If[recordControlParameters == 1, Print[{a, b, c, d}]];
Plot[a*x^3 + b*x^2 + c*x + d, {x, -4, 4}]],
Evaluate@manipulateControlLayoutUsingDivider[
"Row"]@{Style["Amplitudes Sines", 15, Bold], {{a, 1, "a"}, 0,
3}, {{b, 1, "b"}, 0, 3}, Delimiter,
Delimiter, {{g, 1, "g"}, 0, 10}, Delimiter, {{e, 2, "e"}, 0, 5},
Delimiter, {{c, 1, "c"}, 0, 4}, {{d, 0, "d"}, 0, 2},
Delimiter, {{recordControlParameters, 0,
"recordControlParameters"}, {0,
1}}, {{userecordedControlParameters, 0,
"userecordedControlParameters"}, {0, 1}}}, Alignment -> Center,
ControlPlacement -> Left]]
Initialization
option withinManipulate
. $\endgroup$Manipulate
. Possible duplicate: mathematica.stackexchange.com/a/17988 -- I do this for classroom demonstrations. Also related: mathematica.stackexchange.com/a/56368 $\endgroup$Paste Snapshot
command in bookmarks menu, which may be sufficient for your purposes. It pastes aDynamicModule
that constructs theManipulate
body without the controls or surrounding panel. (For that matter,Add to Bookmarks...
from the bookmarks menu may be what you're looking for. Beware that those are saved in theManipulate
and go away if the cell is deleted or overwritten.) $\endgroup$