PDS_kNN/matlab/maxIdx.m

15 lines
251 B
Matlab

function [M, I] = maxIdx(Vec)
%maxIdx Calculate the max,index pair of each element of a vector
%
n = length(Vec);
I = 0;
M = -Inf;
for j = 1:n
if M < Vec(j)
M = Vec(j);
I = j;
end
end
end