MathGroup Archive 2001

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

Search the Archive

Re: simple newbee questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29546] Re: [mg29518] simple newbee questions
  • From: BobHanlon at aol.com
  • Date: Sun, 24 Jun 2001 02:00:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2001/6/23 2:07:47 AM, wzn at jongnederland.nl writes:

>How can I calculate the mean of a matrix (n*m), an array works fine...
>
>How can I select an area in a matix?
>

m = Array[a, {2, 3}];

The means by row

(Plus@@#)/Length[#]& /@ m

{(1/3)*(a[1, 1] + a[1, 2] + a[1, 3]), 
  (1/3)*(a[2, 1] + a[2, 2] + a[2, 3])}

The means by column

(Plus@@#)/Length[#]& /@ Transpose[m]

{(1/2)*(a[1, 1] + a[2, 1]), 
  (1/2)*(a[1, 2] + a[2, 2]), 
  (1/2)*(a[1, 3] + a[2, 3])}

The mean of all elements

(Plus@@#)/Length[#]&[Flatten[m]]

(1/6)*(a[1, 1] + a[1, 2] + a[1, 3] + a[2, 1] + 
   a[2, 2] + a[2, 3])

m = Array[a, {8, 10}];

If you want the intersection of rows (4 - 6) with columns (2 - 5)
m[[Range[4, 6], Range[2, 5]]]


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Re: Equality question
  • Next by Date: Re: Two CPU AMD PC and Mathematica
  • Previous by thread: simple newbee questions
  • Next by thread: Exterior Differential Calculus & Symbolic Matrix Algebra