Message Boards Message Boards

Plot 2D planes of a n-dimensional function with dynamic number of sliders?

Posted 8 years ago

Hello,

I am going to have a n-dimensional function and I would like to able plot 2D planes for the rest of the variables fixed to a number. For example:

u = w^2  y^3 + x^5 z^4 + I z^6 + I z^2 Sin[y + x - 1]+k*Sin[w*pi]

I have 5 variables in here and lets assume I want to fix z w plane and plot with sliding y,z, and k. I have many issues to fix to get what I want to do,

1- As it is the code is not working. I need to figure out to update the limsL and limsR for the sliders. If I remove the doloop and the limits at least I dont get the RED error bar. I need to update those values maybe using a button to get all the data and second button to plot. 2- But even with default limits for sliders [0,1] I do not get a plot. The values are updated at the interface. Under varying variables but does not effect the u function.

Manipulate[
 DynamicModule[{u = 
    z  Sin[\[Pi] x] + Cos[\[Pi] y] + y^6 Cos[2 \[Pi] y], 
   vars = {x, y, z}, varlims = {{1, 2}, {3, 4}, {5, 6}}, poi = {x, y},
    svars = {z, r}, data = Table[RandomReal[], {20}]},
  Column[{Style["Ploter", "Function"],
    Row[{"Function  ", InputField[u]}, Spacer[20]], 
    Row[{"Variables ", InputField[Dynamic[vars]]}], 
    Row[{"Variable limits ", InputField[Dynamic[varlims]]}], 
    Row[{"Plane of interest", InputField[Dynamic[poi]]}], 
    Row[{"Varying variables", InputField[Dynamic[svars]]}],
    Plotslices[u, vars, varlims, poi, svars, size],

    Dynamic[
     countersvar = Dimensions[svars][[1]];
     limsL = ConstantArray[0, countersvar];
     limsR = ConstantArray[0, countersvar];
     Do[

      v = svars[[i]];
      posv = Position[vars, v][[1]];
      lv = varlims[[posv, 1]][[1]];
      rv = varlims[[posv, 2]][[1]];
      limsL[[i]] = lv;
      limsR[[i]] = rv;
      , {i, countersvar}];
     Grid[
      Table[With[{i = i}, {svars[[i]], 
         Slider[Dynamic[svars[[i]], {limsL[[1]], limsR[[i]]}]], 
         Dynamic[svars[[i]]]}], {i, Dimensions[svars][[1]]}]]]


    }]], {size, {Small, Medium, Full}}, ControlPlacement -> Bottom, 
 ContinuousAction -> False, Initialization :> (

   Plotslices[u_, vars_, varlims_, poi_, svars_, size_] := 
     Module[{v1, v2, lv1, lv2, rv1, rv2, posv1, posv2},
      v1 = poi[[1]];
      v2 = poi[[2]];
      posv1 = Position[vars, v1][[1]];
      posv2 = Position[vars, v2][[1]];
      lv1 = varlims[[posv1, 1]][[1]];
      lv2 = varlims[[posv2, 1]][[1]];
      rv1 = varlims[[posv1, 2]][[1]];
      rv2 = varlims[[posv2, 2]][[1]];
      psl = 
       Plot3D[u, {v1, lv1, rv1}, {v2, lv2, rv2}, 
        PerformanceGoal -> "Quality", Mesh -> None, 
        ColorFunction -> Function[{v1, v2, z}, Hue[z]], 
        ImageSize -> size];
      Return[psl];];



   )
 ]
POSTED BY: Erdem Uguz
2 Replies
Posted 8 years ago

I was not able to make it work without DynamicModule. I was getting errors.

POSTED BY: Erdem Uguz

Have not tried your code, but there is no need to use DynamicModule inside Manipulate. What is the reason for doing so? Manipulate itself is DynamicModule to start with.

POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract