2.63 How to find maximum of each row of a matrix?
Given
\[ \left ( {\begin {array} {cc} 1 & 2 \\ 3 & 4 \end {array}} \right ) \]
Find the maximum of each row. The result should be
\((2,4)\). (to find the min, just
change Max with Min below.
| Mathematica
mat = {{1, 2}, {3, 4}}
Map[Max , mat] (* or Max /@ mat *)
|
{2,4}
|
| Matlab
A=[1 2;3 4];
max(A')
|
2 4
|
| Maple
A:=Matrix([[1,2],[3,4]]);
`max`~([LinearAlgebra:-Row(A,1..-1)])
|
[2, 4]
|