MATLAB: Finding minimal vector of matrix

findminimal

Hi, I have matrix where each row represents one vector of two variables (mean and std). I would like to find the index of optimal vector which is defined by minimal mean (first column) and minimal std (second column). It is index=6 (for sixth row) for presented data. How to do this? Thank you for your answers. Martin
0.0026 0.0004
0.0024 0.0003
0.0023 0.0004
0.0027 0.0003
0.0023 0.0003
0.0023 0.0001
0.0025 0.0003
0.0026 0.0002
0.0023 0.0002
0.0025 0.0003
0.0027 0.0007

Best Answer

The sortrows (link) function is one option:
M = [0.0026 0.0004
0.0024 0.0003
0.0023 0.0004
0.0027 0.0003
0.0023 0.0003
0.0023 0.0001
0.0025 0.0003
0.0026 0.0002
0.0023 0.0002
0.0025 0.0003
0.0027 0.0007];
[s,idx] = sortrows(M, [1 2]);
Out = idx(1)
Out =
6