Consider a list of lists of $ m \times n \times 3 $:
{
{{a1, R1, c11}, {a2, R1, c12}, {a3, R1, c13}, ..., {an, R1, c1n}},
{{a1, R2, c21}, {a2, R2, c22}, {a3, R2, c23}, ..., {an, R2, c2n}},
...,
{{a1, Ri, ci1}, ... , {aj, Ri, cij}, ..., Null, Null, Null},
...,
{{a1, Rm, cm1}, {a2, Rm, cm2}, {a3, Rm, cm3}, ..., {an, Rm, cmn}}
}
In each 1st-level list, the 2nd element $ R_i $ is fixed ($ i = 1, 2, ..., m $ for each row), the 1st element changes from $ a_1 $ to $ a_n $. Note that the data is produced by calculation and the elements of the 1st-level list may be Null
, in this case, the Null
should be ignored in the data processing. Here is a minimum sample data.
The question is how to find the maximum of the function $f=a_jc_{ij}$ corresponding to each $R_i$ in order to plot a curve of $f_\mathrm{max}$ vs. $R_i$ ? Thank you for any suggestions.
ListPlot[{#[[1, 2]], Max[First[#]*Last[#] & /@ #]} & /@ array]
, where array is your m by n by 3 list. $\endgroup$Null
in my data, straightforward usage of this command has a problem related to this. Please see my update. Sorry for the missing of the key point. $\endgroup$ListPlot[{#[[1, 2]], Max[First[#]*Last[#] & /@ Cases[#, _List]]} & /@ array]
$\endgroup$#[[1, 2]]
is used to pick out $R_i$ of each row (1st-level list), so the1
can be changed to2
,3
, and so on because each sublist in the 1st-level list has the same $R_i$. Right? But when changing it to, say,2
the command does not work. Why? $\endgroup$