开发者

Entering data with Input[] in mathematica

How can i make in this code the text in Dialog Box of the Input command to be l开发者_StackOverflowike this "Enter the 1 element","Enter the 2 element"....

For[k = 1, k ≤ n, k++,
  br = Input["Enter the ",i,"element"];
  AppendTo[x, br];
]


Make sure your variables match. :-)

You can use Row to build up the text.

x = {};
n = 3;
For[k = 1, k <= n, k++,
 br = Input[Row[{"Enter the ", k, " element"}]];
 AppendTo[x, br];
 ]

(You could also use StringJoin["Enter the ", ToString[k], " element"], but I like Row better.)


According to the Input[ ] help:

The prompt given can be text, graphics or any expression.

So, anything will fit in the input prompt!

Just as an example (note the explicit loop is not needed):

x = Input[
    Panel[Grid@{{Row[{"Enter the element number ", #}]}, 
                     {PolyhedronData["Platonic", {"Image"}][[Mod[#, 5] + 1]]}}]
         ] & /@ Range[1, 5]

Will show things like:

Entering data with Input[] in mathematica

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜