3
$\begingroup$

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?

$\endgroup$
1
$\begingroup$
 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} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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