切片3D绘图和动态数量的控件MATHEMATICA

时间:2016-07-25 22:51:38

标签: wolfram-mathematica

我将有一个n维函数,我希望能够将2D平面绘制为固定为数字的其余变量。例如:

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

我在这里有5个变量,我们假设我想修复z w平面并用滑动y,z和k绘图。我有很多问题需要解决才能得到我想做的事情,

1-因为代码不起作用。我需要弄清楚更新滑块的limsL和limsR。如果我删除doloop和限制至少我没有得到RED错误栏。我需要更新这些值,可能是使用按钮获取所有数据,第二个按钮进行绘图。

2-但即使有滑块[0,1]的默认限制,我也没有得到情节。值在接口处更新。在变量不同但不影响u函数的情况下。实际上我更喜欢变量保持为z,y,x等而不是获得数值。

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];];
)
 ]

我很抱歉格式化。我试着把它放在一起crtl + K但它不起作用。

0 个答案:

没有答案