MathGroup Archive 2009

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

Search the Archive

Re: creating an array in a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100472] Re: [mg100442] creating an array in a loop
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 5 Jun 2009 03:01:20 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

Not clear what you are trying to do.  Try something closer to this.

Func[lmbd_, eps0_] := lmbd + 1 + eps0

Neps = 20;
Nlmbd = 10;

SOL = Table[0, {Nlmbd}, {Neps}];

deps0 = 0.1;

For[lmbd = 0; ieps0 = 1, 
 lmbd <= Nlmbd - 1 && ieps0 <= Neps, 
 lmbd++; ieps0++,
 eps0 = deps0*(ieps0 - 1);
 SOL[[lmbd + 1, ieps0]] = Func[lmbd, eps0]]

SOL


Bob Hanlon

---- "Igor R." <ir12 at mail.gatech.edu> wrote: 

=============
Dear all,

I am new to Mathematica programming
I have the following question.
How to create an array in a loop?
I have the code

=======================================

Neps0;
Nlmbd=10;

Array[SOL,{10,20}]

deps0=0.1; eps0=0.0;
For[lmbd=0; ieps0=1;, \
    lmbd<=Nlmbd-1; ieps0 <= Neps;, \
    lmbd=lmbd+1; ieps0=ieps0+1;,\
    eps0=deps0*(ieps-1);
    SOL[[lmbd+1,ieps]]=Func[lmbd,eps0];
   ]

SOL
=======================================
(where Func[a,b] is some function)

What is wrong with it, why this does not 
work?





--

Bob Hanlon



  • Prev by Date: Re: Problem with a plot in Mathematica
  • Next by Date: Possible bug in Eigenvalues[ ] ???
  • Previous by thread: question on passing arguments in a function within BarChart
  • Next by thread: Re: creating an array in a loop