I have the next code
Manipulate[
Switch[x, a, If[selection =!= None, selection = None], b,
If[selection === None, selection = None], c,
If[selection === None, selection = "Hola"]
];
selection, {x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None},
Switch[x, a, {"recta", "parabola"}, b, {"hiperbola", "absoluto"},
c, {"Seno", "Coseno"}], ControlType -> PopupMenu}
]
but I need you to choose the second popupmenu I plot the function chosen.
Answer
Actually, I have to admit I do not quite understand what you are aiming for, so here's a long shot...
I understand that you want to have values in the second control (selection
) that do depend on the first control, x
that is.
Also, based on the title, I added some plots in the PopupMenu
. Looks fun.
I hope it helps in some way. The key issue is that I introduced a helper, called selChoice
to keep track of the updated selection
-list. selChoice
has ControlType
None
, so you won't see it in the actual Manipulate
.
a = "Algebraicas";
b = "Trigonometricas";
c = "Tercer Grado";
Module[{myPlot},
myPlot[f_] := Plot[f[x], {x, -5, 5}];
Manipulate[
Switch[x,
a, If[selection =!= None, selection = None],
b, If[selection === None, selection = None],
c, If[selection === None, selection = "Hola"]];
selection,
{x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None}, selChoice, ControlType -> SetterBar},
{{selChoice,
Which[x == a, myPlot /@ {# &, #^2 &},
x == b, myPlot /@ {#^3 &, Abs@# &},
x == c, myPlot /@ {Sin, Cos}]}, None}]]
Note that I have no clue what you want to do with the first Switch
... and also note that I am fully aware that my functions do not quite make sense in the respective categories.
Output:
EDIT
Based on the comment, maybe this is more what you want (I am still not sure)
Module[{myPlot}, myPlot[f_] := Plot[f[x], {x, -5, 5}];
Manipulate[
myPlot@selection,
{x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None}, selChoice, ControlType -> SetterBar},
{{selChoice, Which[
x == a, {# &, #^2 &},
x == b, {#^3 &, Abs@# &},
x == c, {Sin, Cos}]}, None}]]
Comments
Post a Comment