2
$\begingroup$

I'm trying to create a variable in Manipulate[] with a subscript in its name with the following code:

{{Subscript[r, b], 175.0, "Base radius"}, 127.0, 254.0, 1.0, Appearance -> "Labeled", ImageSize -> Tiny},

But, I've got an error message saying that the variable specification is incorrect.

Given that I can name variables like that outside Manipulator variables' specification, is it possible to overcome this behavior and define a Manipulator variable with such a name?

Best Regards,

$\endgroup$
  • $\begingroup$ Post a minimal working example. That means all the code we need to get the same error. $\endgroup$ – N.J.Evans Jun 2 '15 at 20:33
  • 2
    $\begingroup$ Its actually quite interesting numeric subscripts will work Manipulate[Plot[Sin[x (1 + Subscript[a, 1]x)], {x, 0, 6}], {Subscript[a, 1], 0, 2}] will. Alpha subscripts Manipulate[Plot[Sin[x (1 + Subscript[a, i]x)], {x, 0, 6}], {Subscript[a, i], 0, 2}] doesn't. Also double quoting the subscript doesn't make a difference. Possible bug? $\endgroup$ – Gordon Coale Jun 2 '15 at 20:37
2
$\begingroup$

As a workaround you can Set the variable Subscript[r, b] to the value of the manipulator variable.

Manipulate[
 Subscript[r, b] = rb;
 f[Subscript[r, b]],
 {{rb, 175.0, "Base radius"}, 127.0, 254.0, 1.0,
  Appearance -> "Labeled", ImageSize -> Tiny}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Using HoldForm on the Variable is a nice little improvement. Manipulate[Subscript[r, b] = rb; f[rb], {{rb, 175.0, HoldForm@Subscript[r, b]}, 127.0, 254.0, 1.0, Appearance -> "Labeled", ImageSize -> Tiny}] $\endgroup$ – Gordon Coale Jun 2 '15 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.