i have matrix 2 columns , multiple row. find index of minimum value in first column value column 2 smaller 5 example.
here example:
x = [3,2;2,4;1,6];
i result index 2 because 2 min of column 1 conditioned on fact column 2 smaller 5.
is there quicker way in matlab. current solution is:
indicescandidates = x(:,2) < 5; minvalue = min(x(indicescandidates,1)); indicesmin = find(x(:,1) == minvalue)
thank you!
and of course one-liner without changing anything
[~,indices] = min(x(x(:,2) < 5,1));
the real question mean quicker? if profile things same.
Comments
Post a Comment