MathGroup Archive 2008

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

Search the Archive

Re: setting elements of an array based on a condition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87182] Re: setting elements of an array based on a condition
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 3 Apr 2008 05:16:33 -0500 (EST)

On 4/2/08 at 5:57 AM, szhorvat at gmail.com (Szabolcs Horv=C3=A1t) wrote:

>Claus wrote:

>>2) Then I want to calculate the sum of the elements in each column
>>of W. How can I do this?

>Plus @@@ W

>or

>Total /@ W

For a 2 x 2 (W) matrix, your code will output

W[[1,1]]+W[[1,2]] and
W[[2,1]]+W[[2,2]]

I believe the requester is asking for

B[[1,1]]+B[[2,1]] and
B[[1,2]]+B[[2,2]]

For that you would want to use

Total[W]

or

Plus@@@Transpose[W]


  • Prev by Date: Re: How to put text on a curved surface?
  • Next by Date: Re: How to put text on a curved surface?
  • Previous by thread: Re: setting elements of an array based on a condition
  • Next by thread: Re: setting elements of an array based on a condition