# Why doesn't Manipulate work? [duplicate]

plotb[{yLow_, yHigh_, x_, xLeft_, xRight_}] :=
Plot[{If[yLow < yHigh, yLow], If[yLow < yHigh, yHigh]} , {x, xLeft, xRight},
Filling -> {1 -> {2}}]
d[decesion_] := Table[plotb[decesion[[i]]], {i, 1, Length[decesion]}]
c = {{2/h + a + b, 3 h - a + 2 b, h, 0, 10}, {h + 2 a - b,4 h - a + b, h, 2 b, 6}};
Manipulate[Show[d[c]], {a, 0, 2}, {b, 0, 5}]


I have many graphics to draw and the c list includes many sublists. I have three questions:

1. Manipulate doesn' t work.
2. I want to fill the regions when yLow < yHigh and just use Plot not use RegionPlot. It seems to be reduntant using two "if" expressions. I don't know whether it will be slow when c includes a lot of sublists due to the two reduntant "if" expressions.
3. 2/h in c will be wrong when h is 0. Maybe it can work if I change 0 to 0.001. Is there any other way not to modify c. Because I have completed the list c, I don't want to modify it.

Thank you very much.

• Also, see: mathematica.stackexchange.com/q/25087/1871 Since you can read Chinese, consider reading this tutorial: note.youdao.com/ynoteshare1/… To be more specific, define c as a function is the standard solution: Clear[c]; c[a_, b_] =…  Jul 12, 2020 at 2:30
• @xzczd Thank you for your suggestion. I search the solution in the website, but don't find them that you find. That resolve my question. Just doubt why do you know I can read Chinese. Jul 12, 2020 at 4:46
• Because I see your post in Tieba. Jul 12, 2020 at 5:19

I would not write your code the way you did. But for a quick fix for now, simply add LocalizeVariables -> False

plotb[{yLow_, yHigh_, x_, xLeft_, xRight_}] :=
Plot[{If[yLow < yHigh, yLow], If[yLow < yHigh, yHigh]}, {x, xLeft,
xRight}, Filling -> {1 -> {2}}]
d[decesion_] := Table[plotb[decesion[[i]]], {i, 1, Length[decesion]}]
c = {{2/h + a + b, 3 h - a + 2 b, h, 0, 10}, {h + 2 a - b,
4 h - a + b, h, 2 b, 6}};
Manipulate[
Show[d[c]],
{{a, 0, "a"}, 0, 2, 1, Appearance -> "Labeled"},
{{b, 0, "b"}, 0, 5, 1, Appearance -> "Labeled"},
TrackedSymbols :> {a, b},
LocalizeVariables -> False
]


If you want slider to move with smaller steps, replace

 {{a, 0, "a"}, 0, 2, 1, Appearance -> "Labeled"},
{{b, 0, "b"}, 0, 5, 1, Appearance -> "Labeled"},


with

 {{a, 0, "a"}, 0, 2, 0.1, Appearance -> "Labeled"},
{{b, 0, "b"}, 0, 5, 0.1, Appearance -> "Labeled"},

• Thank you. The LocalizeVariables -> False makes the variables as global. Other graphics will change due to the global variable because I draw many graphics in the note. It will run slow. Jul 10, 2020 at 17:36
• @user73722 As I mentioned, I would not do it that way, but this is how your code is setup. It would be better to put all the functions used by Manipulate inside it. Jul 10, 2020 at 23:06