首页 > 解决方案 > Wolfram 中的动态操作函数?

问题描述

我正在为模拟滤波器设计的数字 GUI 编写演示。由于演示只允许一个 Manipulate 函数,有没有办法动态更新我的 Manipulate 控件?

例如,我有 4 种不同的滤波器类型(低通、高通、带通、带阻),前两种只需要两个频率输入,而后两种需要四个频率输入。有没有办法在不嵌套 Manipulates 的情况下根据选择的模式在两个 Manipulate 滑块和四个之间切换?或者,我可以全部四个并在不需要时将两个灰显吗?

标签: wolfram-mathematicawolfram-language

解决方案


这是一个动态更改Manipulate控件的示例,应该易于修改以实现您想要的。不是我写的,也不记得在哪里看到的。

Manipulate[
 {x, yyy},
 {{x, a}, {a, b, c, d}, None},
 {{yyy, 0.5}, 0, 1, None},
 {{type, 1}, Range@3, None},
 PaneSelector[{
   1 -> Column[{
      Control@{x, {a, b, c, d}, RadioButtonBar},
      Control@{{yyy, 0.5}, 0, 1},
      Control@{type, Range@3}
      }],
   2 -> Column[{
      Control@{x, {a, b, c, d}, SetterBar},
      Control@{yyy},
      Control@{type, Range@3}
      }],
   3 -> Column[{
      Control@{x, {a, b, c, d}, PopupMenu},
      Control@{{yyy, 0.5}, 0, 1},
      Control@{type, Range@3}
      }]
   }, Dynamic@type]     
]

推荐阅读