Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Using variable name as string AND value ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106952] Using variable name as string AND value ?
  • From: Paul <pkshreeman at gmail.com>
  • Date: Fri, 29 Jan 2010 07:47:24 -0500 (EST)

In process of writing a certain routine, I am puzzled to how to write
this concept into Mathematica format.  What I need to do is be able to
extract both string and values, p1 as parameter number one, p2 as
parameter number 2, etc...and I have to put all values into one single
matrix to do some mathematical operations.  However, I also have to
call a function that depends on using the variable p1,p2, so I have to
reassign the values back as following

p1=10
p2=23
...

Parameter={p1,p2,......}   and perhaps Strings={"p1","p2",...}?

After mathematical manipulations of matrix Parameter is done, I can
manually do this

p1=Parameter[[1]],
p2=Parameter[[2]],
....

But I need to be able to do it with Do Loop such as

Do[
String[[j]]=Parameter[[j]]
,{j,1,PL}]

The problem is that this approach doesn't work in Mathematica...what
is solution other than typing all names of variables out again and
again?  This particular routine is designed to manipulate the
variables and feed it back to my main routine with same symbols but
different values, and the parameters vary (numbers, names ,etc) and I
don't want to rewrite the whole routine every time for different
parameters.  I am currently using Mathematica 5.0 ( I know I know..I
need Mathematica7,...)


  • Prev by Date: A repair to Real Number comparison so Fateman's examples do not exhibit
  • Next by Date: Re: Re: Journals dying?, apparently rather slowly (was
  • Previous by thread: A repair to Real Number comparison so Fateman's examples do not exhibit
  • Next by thread: Re: Using variable name as string AND value ?