Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Indexed variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24675] Re: Indexed variables
  • From: Rainer Gruber <rainer.gruber at jk.uni-linz.ac.at>
  • Date: Fri, 4 Aug 2000 01:19:00 -0400 (EDT)
  • Organization: Johannes Kepler Universitaet Linz
  • References: <8lsup5$26a@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Barbara Da Vinci wrote:

> Hello, MathGroup
> Is there anybody who knows as to thrust indexed
> variables in Mathematica without assigning them a
> value ? I need a[[1]] ... a[[8]] to be real headed
> expressions (variables, if you like) present in some
> equations as unknowns.
> I tried a=Table[0,{k,1,8}] but it hampers me because
> of zero value.
> Goodbye
> Barbara Da Vinci
>
> ______________________________________________________________________
> Do You Yahoo!?
> Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it

I have a simple solution for a list of indexed variables with string
manipulation:

First define a function h that yields a "quasi indexed" variable (the
index is part of its name):
In[1]:=
h[i_Integer] := ToExpression["a" <> ToString[i]]

With this function you can generate a list of variables, e. g.
In[2]:=
a = Table[h[i], {i, 1, 5}]
Out[2]=
{a1, a2, a3, a4, a5}

You can refer to the variables as usual (as long as you don't assign
anything else to "a"!) e. g.:
In[3]:=
a[[3]]
Out[3]=
a3

Rainer Gruber
JOHANNES KEPLER UNIVERSITY LINZ
                     Institute of Experimental Physics
               Atomic Physics and Surface Science
(rainer.gruber at jk.uni-linz.ac.at)



  • Prev by Date: Re: Tabular output
  • Next by Date: Mathematica won't solve simple diff. eqn. system
  • Previous by thread: Re: Tabular output
  • Next by thread: Re: Indexed variables