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