MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to make myVec[v,3] to return {v_1, v_2, v_3} ?


Hi.

Everything has been converted to InputForm.

Among many alternatives try this...

In[3]:=
myvec[v_, i_] := Array[v, i]

In[5]:=
myvec[v, 10]
% /. (a_)[i_] :> Subscript[a, i]

Out[5]=
{v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]}

Out[6]=
{Subscript[v, 1], Subscript[v, 2], Subscript[v, 3], Subscript[v, 4],
Subscript[v, 5], Subscript[v, 6], Subscript[v, 7],
  Subscript[v, 8], Subscript[v, 9], Subscript[v, 10]}

Dimitris

=CF/=C7 T.Sariyski =DD=E3=F1=E1=F8=E5:
> Hi,
>
> I want to define a function that takes a symbol and integer and
> generates a vector e.g. myVec[v,3] returns  {v_1, v_2, v_3}? I tried
>
> Table[v_Subscript_i, {i, 1, 3}]
>
> but it returns {v_i, v_i, v_i}
>
> Thanks,
> Ted
>
>
> In[1406]:=
> Table[v\[UnderBracket]Subscript\[UnderBracket]i, {i, 1, 3}]



  • Prev by Date: Re: Re: Interpreting the solutions... better this time
  • Next by Date: Re: equation solving in a markov model
  • Previous by thread: Re: how to make myVec[v,3] to return {v_1, v_2, v_3} ?
  • Next by thread: Overlaying 3d plots