2

I have a list defined as MarsDisk which, in MatrixForm, has 17 rows and 3 columns, which hold information about a photon energy level, photon flux, and uncertainty in the flux. I'm interested in taking the average of the energy levels and executed the following:

Average[MarsDisk[[i, 2]]]

and I received this error message:

Part::partw: Part 18 of {{0.8725,0.5,0.5},{0.817,0.4,0.4},[continues with the rest of my data points]} does not exist. >>

I don't get why this doesn't work because I never asked for the 18th element.

Then, I tried to create a For loop instead:

ψ = Array[c, {17, 2}];

For [i = 1, i <= 17, i++,

 ψ[[i, 1]] = Avg[MarsDisk[[i, 1]]];

 ψ[[i, 2]] = Avg[MarsDisk[[i, 2]]]]

which gave no error message but when I executed ψ it printed all elements as {Avg[0.8725], Avg[0.5]}, etc. So neither way worked.

Can anyone show me a way to successfully quantify the averages for each column of information in my matrix?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574

1 Answers1

2
 matrix = Table[RandomReal[], {n, 1, 17}, {i, 1, 3}]

 Mean[matrix[[All, 2]]]

and i get the result

Alucard
  • 2,639
  • 13
  • 22