# How to find the maximum values and the place of the max value in the list? [duplicate]

I have given an example to find the maximum value and its place in the list. Is it possible to find the local maximum in the sub-list of this list means local maximum in the each row of the list and its place.

{{0.798434, 0.836162, 0.866566, 0.891023, 0.910648, 0.926344,
0.938842, 0.948735, 0.956506, 0.962542, 0.967162, 0.970621,
0.973129, 0.974854, 0.975934, 0.976483, 0.97659, 0.976331, 0.975766,
0.974944, 0.973908}, {0.805793, 0.871229, 0.913967, 0.941624,
0.959219, 0.970068, 0.976365, 0.979565, 0.980639, 0.980232, 0.97878,
0.976576, 0.97382, 0.970649, 0.967158, 0.963416, 0.95947, 0.955357,
0.951105, 0.946734, 0.942261}, {0.806828, 0.895766, 0.943,
0.967386, 0.979126, 0.983757, 0.984299, 0.982413, 0.979023,
0.974652, 0.969603, 0.964063, 0.958146, 0.951933, 0.94548, 0.93883,
0.932018, 0.925073, 0.918018, 0.910877, 0.903666}}

• Welcome to Mathematica.SE, so just to be clear: you want to find the maximum value in each column of the given matrix? – C. E. May 21 '14 at 23:15
• yes and its place... – santosh May 21 '14 at 23:16
• I'm still uncertain about what you are asking. You give a 3 x 21 matrix. You mention the maximum for the whole matrix, the maximum in each "sub-list" (3 values) and the maximum for each column (21 values). Which do you want? – m_goldberg May 21 '14 at 23:30
• maximum in each "sub-list" (3 values) – santosh May 21 '14 at 23:33
• The positions are given by pos=Last@Ordering@#&/@list, so to get the value and the position you can do something like {#,list[[#]]}&/@pos. – C. E. May 21 '14 at 23:44

This problem can be tackled in many ways with Mathematica. Here is one way to do it.

data =
{{0.798434, 0.836162, 0.866566, 0.891023, 0.910648, 0.926344,
0.938842, 0.948735, 0.956506, 0.962542, 0.967162, 0.970621,
0.973129, 0.974854, 0.975934, 0.976483, 0.97659, 0.976331, 0.975766,
0.974944, 0.973908},
{0.805793, 0.871229, 0.913967, 0.941624,
0.959219, 0.970068, 0.976365, 0.979565, 0.980639, 0.980232, 0.97878,
0.976576, 0.97382, 0.970649, 0.967158, 0.963416, 0.95947, 0.955357,
0.951105, 0.946734, 0.942261},
{0.806828, 0.895766, 0.943,
0.967386, 0.979126, 0.983757, 0.984299, 0.982413, 0.979023,
0.974652, 0.969603, 0.964063, 0.958146, 0.951933, 0.94548, 0.93883,
0.932018, 0.925073, 0.918018, 0.910877, 0.903666}};

rowMaxes[data_] :=
Module[{vals, indxs},
vals = Max /@ data;
Range @ Length @ data,
}];

{{0.97659, {1, 17}}, {0.980639, {2, 9}}, {0.984299, {3, 7}}}

intData = {{1, 2, 4, 4}, {4, 5, 7, 4}, {1, 2, 10, 4}};

{{4, {1, 3}}, {7, {2, 3}}, {10, {3, 3}}}