Wolfram mathematica Mathematica-将操纵[]与物理单位一起使用
我是一个新用户,正在尝试用Mathematica建立一个简单的波义耳定律系统。我想包括值的单位,因为我以后可能需要执行一些转换。如果我的数量是一个离散的列表,那么它们工作得很好。我似乎无法让它为滑块工作 在发布这个问题之前,我已经搜索了一段时间。这是我的密码:Wolfram mathematica Mathematica-将操纵[]与物理单位一起使用,wolfram-mathematica,units-of-measurement,Wolfram Mathematica,Units Of Measurement,我是一个新用户,正在尝试用Mathematica建立一个简单的波义耳定律系统。我想包括值的单位,因为我以后可能需要执行一些转换。如果我的数量是一个离散的列表,那么它们工作得很好。我似乎无法让它为滑块工作 在发布这个问题之前,我已经搜索了一段时间。这是我的密码: Manipulate[ Text@Style[ Grid[{ {Row[{"Total fill volume is ", totalVolume}]}, {Row[{"
Manipulate[
Text@Style[
Grid[{
{Row[{"Total fill volume is ", totalVolume}]},
{Row[{"Delivery rate is ", deliveryRate}]},
{Row[{"Product duration is ",
duration[totalVolume, deliveryRate]}]},
{Row[{}]},
{Row[{"Initial pressure is ", initialPressureG}]},
{Row[{"Drop in pressure is ", pressureDrop, "%"}]}
}, Alignment -> Left]
]
,
{{totalVolume, Quantity[30, "ml"], "Total fill volume"},
Quantity[{30, 45, 60, 90}, "ml"]},
{{deliveryRate, Quantity[1, "ml/day"], "Delivery rate"},
Quantity[{0.5, 1, 2, 3}, "ml/day"]},
{initialPressureG, 0, 100},
{{pressureDrop, 40, "Pressure drop"}, 0, 100, 5}
]
我希望它是一个从0psi到100psi的滑块,而不是一个从0到100的滑块。我是否犯了愚蠢的错误?一个可能的解决方案是保持滑块值为纯数字,并分别将其转换为完整数量。例如:
Manipulate[DynamicModule[{valueWithQuantity = Quantity[value, "A"]},
valueWithQuantity],
{value, 0, 100}
]
这种方法也可以在代码中使用
Manipulate[
DynamicModule[{pressureDrop = Quantity[pD, "psi"]},
Text@Style[
Grid[{{Row[{"Total fill volume is ",
totalVolume}]}, {Row[{"Delivery rate is ",
deliveryRate}]}, {Row[{"Product duration is ",
duration[totalVolume,
deliveryRate]}]}, {Row[{}]}, {Row[{"Initial pressure is ",
initialPressureG}]}, {Row[{"Drop in pressure is ",
pressureDrop, "%"}]}}, Alignment -> Left]]
], {{totalVolume, Quantity[30, "ml"], "Total fill volume"},
Quantity[{30, 45, 60, 90}, "ml"]}, {{deliveryRate,
Quantity[1, "ml/day"], "Delivery rate"},
Quantity[{0.5, 1, 2, 3}, "ml/day"]},
{initialPressureG, 0, 100},
{{pD, 40, "Pressure Drop"}, 0, 100, 5}
]
你会得到你所期望的。开始你的问题,你可能会得到更好的答案。