MathGroup Archive 2006

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

Search the Archive

Re: decrementing problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72314] Re: [mg72293] decrementing problem
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 26 Dec 2006 05:14:23 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200612181156.GAA02194@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Why bother with a For loop when Mathematica can handle the details for you:

   n=5;
   U=Table[Random[Real],{i,n},{j,n}];
   X=Table[Random[Real],{j,n}];
   Sum[U[[i,j]] X[[j]],{i,n-1,1,-1},{j,i+1,n}]
0.832632


jltrahan at mail.usf.edu wrote:
> Hi,
> I am having a really difficult time with decrementing values in my For
> loop. I have tried i--, --i, i-=1, i=i-1, and nothing is working. The loop
> is as follows:
> For[i=n-1, i<=1, i--, summ=0;
>    For[j=i+1, j<=n, j++, summ=summ + U[[i,j]]*X[[j]]]
> ]
> When I try to print i or j, nothing shows up.
> Can anyone please help?
> 
> Thank you in advance,
> Jamie
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: image border
  • Next by Date: RE: Re: image border
  • Previous by thread: Re: decrementing problem
  • Next by thread: Re: decrementing problem