Message Boards Message Boards

Add constraints to Manipulate?


My question is: how can I add constraints to Manipulate? This my Code:

  ListPlot[data, PlotStyle -> Red],
  Plot[func[x, Ax, Az, Bx, Bz, Cx, Cz, Dx, Dz], {x, -10, 10}, PlotStyle -> Darker[Gray]],
  PlotRange -> All],
 {{Ax, 0.12}, -1, 1, Appearance -> "Open"},
 {{Az, -0.043}, -1, 1, Appearance -> "Open"},
 {{Bx, -0.102}, -1, 1, Appearance -> "Open"},
 {{Bz, -0.031}, -1, 1, Appearance -> "Open"},
 {{Cx, 0.032}, -1, 1, Appearance -> "Open"},
 {{Cz, -0.026}, -1, 1, Appearance -> "Open"},
 {{Dx, 0.95}, -1, 1, Appearance -> "Open"},
 {{Dz, 0.1}, -1, 1, Appearance -> "Open"}]

I need to add two following constraints to Manipulate:

(Ax+Bx+Cx+Dx ==1) , (Az+Bz+Cz+Dz==0)

How can add these two constraints to Manipulate? Thanks for your help.

POSTED BY: Hamidreza Khataee
4 months ago


Look at “Interdependent Controls” in the documentation here. It describes what you want. Your only issue will be deciding which variable to change to meet your constraints (ie Ax, or Bx, etc.) it would be straightforward if you always adjust one variable, for example, Bx, to meet your constraint, but you may find situations in which it exceeds its limits. You can also choose one based on their current values (ie. Max or Min or nearest to 0).

If you use Dynamic instead of Manipulate you can choose which variable to adjust based on which one is being manipulated. See “the second argument of Dynamic” in the documentation here



POSTED BY: Neil Singer
4 months ago

Group Abstract Group Abstract