Finding minimal vector of matrix

1 view (last 30 days)
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

Accepted Answer

Star Strider
Star Strider on 17 Oct 2018
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

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!