Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: Can't assign value to symbols

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58448] Re: [mg58409] Can't assign value to symbols
  • From: yehuda ben-shimol <bsyehuda at gmail.com>
  • Date: Sat, 2 Jul 2005 04:07:11 -0400 (EDT)
  • References: <200507010602.CAA09182@smc.vnet.net>
  • Reply-to: yehuda ben-shimol <bsyehuda at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
not that parameters[[1,1]]  is a, but when you try to assign a value
to parameters[[1,1]] it does not change a, but changes
parameters[[1,1]], so the pointers paradigm from other languages is
not appropriate in the Mathematica language.
still you have other ways to go arround.
Since you probably have the same function (i.e., simulation) you want
to e valuate for different sets of values for a, b, c you can use
rules,
say your function is
f=(a+2b)*c
and the set of values is
p = {{a, b, c}, {1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
then
f/.Map[Thread[Rule[First[p], #]] &, Rest[p]]
will return a list of results.
yehuda
On 7/1/05, Lee Newman <leenewm at umich.edu> wrote:
> Hello,
> 
> Situation:  I have a table that contains parameters and sets of values
> that I want to assign to the parameters for the purposes of running a
> simulation.
> - parameters = {{a,b,c},{1,2,3},{4,5,6},{7,8,9}}
> - want to assign values in a given row to the symbols listed in the
> first row.
> - tried using:  MapThread[  #1 = #2 &, {parameters[[1]], parameters[[3]]} ]
> - fails with error  "Tag Slot in #1 is Protected"
> - tried adding Unprotect[#1] and a variety of other attemps, but can't
> get it to work.
> 
> Anyone know how might accomplish this?
> 
> Thanks,
> Lee
> 
> 
>


  • Prev by Date: Re: Can't assign value to symbols
  • Next by Date: Re: Explicit solution to Root[]
  • Previous by thread: Re: Can't assign value to symbols
  • Next by thread: Re: Can't assign value to symbols