I want to use a generic function to generate controls in manipulate, which looks like this:
lincontrol[variable_, default_, min_, max_] :=
{{{variable, default}, min, max},
Panel[ToString[variable ] <> "=" Dynamic[variable]]}
so that I can use it inside a module like this:
Manipulate[Module[{spectrum},
spectrum = y^2 + a*x + b;
Plot[spectrum, {x, -10, 10}]],
Flatten[{lincontrol[#, 1, 0, 10] &/@ {y,a,b}}, 2]]
The idea is that lincontrol
would generate a controller and display panel for y,a,b
. The problem is that lincontrol
is returning a list, whereas Manipulate
just wants to take a series of arguments. I've used Flatten
to get rid of the extra list layers, but I can't remove the 'outer' list. Any ideas?
Evaluate[Sequence @@ Flatten[{lincontrol[#, 1, 0, 10] & /@ {y, a, b}}, 2]]
$\endgroup$spectrum = (x=y^2 +a*b;
. You have no closing parenthesis. Maybe you meanx*y^2+a*b
? $\endgroup$