From: S. B. Gray on
How can you create a set of variables: x1 to xn using the Table, or some
similar function? I need a large list of variables to use in a linear
program and so far have to type them out manually.

David


One easy was is for example ta = Table[Subscript[q, j], {j, 10}].
This gives you 10 subscripted variables. Then you can do the usual
operations such as Subscript[q,5]=7 . Then ta is

{Subscript[q, 1], Subscript[q, 2], Subscript[q, 3], Subscript[q, 4], \
7, Subscript[q, 6], Subscript[q, 7], Subscript[q, 8], Subscript[q, \
9], Subscript[q, 10]}

It is easier to bring up the Basic Math palette and use it to make the
subscripts rather than using Subscript[ ].

From: Peter Pein on
Am Thu, 10 Jun 2010 12:10:50 +0000 (UTC)
schrieb "S. B. Gray" <stevebg(a)ROADRUNNER.COM>:

> How can you create a set of variables: x1 to xn using the Table, or
> some similar function? I need a large list of variables to use in
> a linear program and so far have to type them out manually.
>
> David
>
> ...
something like
In[1]:= Table[ToExpression["x"<>ToString[k]],{k,0,10}]
Out[1]= {x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10}
?

From: Srikanth K S on
*Dear Steve,

Subscript[q, #] & /@ Range[10]

Seems simple to me!
Further if you wanted to generate a matrix,

Table[Subscript[q, i, j], {i, 1, 3}, {j, 1, 4}] gives

{{Subscript[q, 1, 1], Subscript[q, 1, 2], Subscript[q, 1, 3],
Subscript[q, 1, 4]}, {Subscript[q, 2, 1], Subscript[q, 2, 2],
Subscript[q, 2, 3], Subscript[q, 2, 4]}, {Subscript[q, 3, 1],
Subscript[q, 3, 2], Subscript[q, 3, 3], Subscript[q, 3, 4]}}
*---


2010/6/10 S. B. Gray <stevebg(a)roadrunner.com>

> How can you create a set of variables: x1 to xn using the Table, or some
> similar function? I need a large list of variables to use in a linear
> program and so far have to type them out manually.
>
> David
>
>
> One easy was is for example ta == Table[Subscript[q, j], {j, 10}].
> This gives you 10 subscripted variables. Then you can do the usual
> operations such as Subscript[q,5]==7 . Then ta is
>
> {Subscript[q, 1], Subscript[q, 2], Subscript[q, 3], Subscript[q, 4], \
> 7, Subscript[q, 6], Subscript[q, 7], Subscript[q, 8], Subscript[q, \
> 9], Subscript[q, 10]}
>
> It is easier to bring up the Basic Math palette and use it to make the
> subscripts rather than using Subscript[ ].
>
>