I made a Manipulate box that is working very well, using lots of random numbers. I would like to add a button to "reset" (i.e. to change, randomize, or reselect) all the random parameters.
Here's the code I added to the Manipulate box, but it doesn't work :
Row[{Spacer[200], Button[ "Randomize all parameters", Clear["alpha", "Phase", "Amplitude", "Frequency"], Appearance -> "Palette", ImageSize -> {150, 28} ] }], What should I use instead of Clear["alpha", "Phase", "Amplitude", "Frequency"] to randomize all these parameters, according to their definitions ?
EDIT : Here's a complete MWE showing the problem :
Clear["Global`*"] Amplitude[k_] := Amplitude[k] = RandomReal[{0.5, 1.5}] Frequency[k_] := Frequency[k] = RandomReal[{1, 5}] Phase[k_] := Phase[k] = RandomReal[{0, 2Pi}] Manipulate[ Plot[ Sum[Amplitude[k]Sin[2Pi Frequency[k]t + Phase[k]], {k, 1, Nwaves} ], {t, 0, 1}, Frame -> True, PlotRange -> {{0, 1}, {-5, 5}}, PerformanceGoal -> "Quality", ImageSize -> 600 ], {{Nwaves, 1, Style["Number of waves", 10]}, 1, 20, 1, Appearance -> "Labeled"}, Delimiter, Row[{ Button[ "Reset random parameters", {(* Reset command for "Amplitude", "Frequency", "Phase" *)}, Appearance -> "Palette", ImageSize -> {250, 28} ] }], ControlPlacement -> Bottom ] EDIT 2 : The "duplicate" referenced above doesn't apply to this question, since the answers are specific to that question. I don't see how to apply them to the question here.
DownValues. Something like,DownValues[alpha] = DownValues[alpha][[{-1}]], which resets the rules associated withalphato only the original definition. Without an idea of what's happening inside theManipulate, that's the best I can say right now. $\endgroup$