Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Assign value to variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111254] Re: Assign value to variable
  • From: James Stein <mathgroup at stein.org>
  • Date: Sun, 25 Jul 2010 01:59:06 -0400 (EDT)

Perhaps something like this?

n = 4; (* # of desired variables *)
co = Table["co" <> ToString[i], {i, 1, n}];
For[ i = 1, i <= n, i++, co [ [ i ] ] = i ^ 2 ] ;



On Sat, Jul 24, 2010 at 2:07 AM, miguelwon <miguelwon at gmail.com> wrote:

> Hello.
>
> I'm working with some expressions that are dependent of several
> variables co1, co2, ... , con. I would like to know how can I assign
> values iteratively to some of these variables. I tried:
>
> For[i=1,i<=100,i++,
> Symbol["co"<>ToString[i]]=0;
> ];
>
> but it doesn't work. For each iteration it says coi is Protected.
> Can someone help me?
>
> Thanks
>
>


  • Prev by Date: Re: Subscript in AxesLabel
  • Next by Date: Documentation on (Color) Blend
  • Previous by thread: Assign value to variable
  • Next by thread: Re: Assign value to variable