Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Imagine I have a matrix of the following form:

TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be:

TestArray = $((10^6,1,...),(10^7,7,...),(10^3,4,...))$

In the above example, we have $Max[a_i] = 10^7$, and $Max[b_i] = 7$.

In a single line of Mathematica, how can I find the maximum $a_i$, $b_i$, etc.? Moreover, what is the most computationally efficient manner in which to do this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
 array = RandomInteger[10^5, {20, 5}];

 array // TableForm

enter image description here

 Max /@ Transpose@array
 (* {93950, 99694, 94568, 97340, 90524} *)

or

 #[[Ordering[#, -1]]][[1]] & /@ Transpose[array]
 (* {93950, 99694, 94568, 97340, 90524} *)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.