Mathematica中的对数滑块控制

ter*_*ace 5 user-interface wolfram-mathematica widget

我正在为Mathematica中的分压器计算一个小接口.我有两个滑块(z1和z2)代表电阻值,还有几个滑块代表Vin作为正弦曲线.

问题是可用电阻值的范围(在现实世界中)大致为对数{r, 100, 1,000,000}.r但是,如果我将滑块范围设置为,则选择常见的低电阻值是不切实际的.{100, 10,000}.

是否可以创建一个扫过对数范围的滑块?

Manipulate[
 Grid[{{Plot[(VinRCos[t] + VinC), {t, -3, 9}, 
     PlotRange -> {-1, VMax}, AxesLabel -> {t, Vin}]}, {Plot[
     z2/(z1 + z2)(VinR*Cos[t] + VinC), {t, -3, 9}, 
     PlotRange -> {-1, VMax}, AxesLabel -> {t, Vout}]}}, 
  ItemSize -> 20],
 {{z1, 10000}, 10, 1000000, 10}, {z1}, {{z2, 10000}, 10, 
  1000000}, {z2}, Delimiter, {{VinR, 2.5}, 0, 
  5}, {VinR}, {{VinC, 2}, -VMax, VMax}, {VinC}]
Mathematica图形

Sim*_*mon 7

迈克尔的答案可能是最好的,即只是让用户指定指数.另一种解决方案是创建一个LogSlider类型命令.这是一个简单的例子:

LogSlider[{v:Dynamic[var_], v0_?Positive}, {min_?Positive, max_?Positive}, 
   base_:10, options___] := DynamicModule[{ev}, Dynamic[
                              var = base^ev; 
                              Slider[Dynamic[ev], Log[base, {min, max}]]]]
LogSlider[v:Dynamic[var_], {min_?Positive, max_?Positive}, 
   base_:10, options___] :=  LogSlider[{v, min}, {min, max}]
Run Code Online (Sandbox Code Playgroud)

该功能只有一部分灵活性,Slider如果你想要自定义步长等,则必须扩展...

然后Manipulate通过使用{{z1, 10000}, 10, 1000000, LogSlider[##]&}等指定变量来修改您的 ...


Mic*_*lat 6

一个简单的解决方法是让滑块操纵指数,并插入例如10^z1您需要实际值的位置:

Manipulate[10^z1, {{z1, 5}, 2, 6}] (* 100 to 1M *)
Run Code Online (Sandbox Code Playgroud)

在您的特定情况下,您当然也可以输入一个标准电阻值列表来选择:

Manipulate[z1, {z1, {100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270}}]
Run Code Online (Sandbox Code Playgroud)

HTH!