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?
Forloop, then at the end of that evaluationiwill be 18. This could explain the error message fromPartyou are seeing. – Arnoud Buzing Aug 11 '16 at 16:51Averageis not a built-in function. Have you looked at Mean – Bob Hanlon Aug 11 '16 at 17:13