Suppose I have something like
Manipulate[Plot[Sin[n x], {x, -Pi, Pi}], {n, 20, "Frequency"}]
with a manual input field but I want to accept inputs like 20 Hz
. Is there any way of doing that?
Does it fit your needs?
Manipulate[
Plot[Sin[hz x], {x, -Pi, Pi}]
, { {input, "1 Hz", "Frequency"}
, InputField[#, String, ##2] &
, TrackingFunction :> Function[
new
, Catch[
hz = Check[
QuantityMagnitude[Interpreter["Quantity"] @ new, "Hertz"]
, Throw @ $Failed
]
; input = new
]
]
}
, {{hz, 1}, None} (*just for scoping*)
]