matthiasm@8: function indices = argmax(v) matthiasm@8: % ARGMAX Return as a subscript vector the location of the largest element of a multidimensional array v. matthiasm@8: % indices = argmax(v) matthiasm@8: % matthiasm@8: % Returns the first maximum in the case of ties. matthiasm@8: % Example: matthiasm@8: % X = [2 8 4; 7 3 9]; matthiasm@8: % argmax(X) = [2 3], i.e., row 2 column 3 matthiasm@8: matthiasm@8: [m i] = max(v(:)); matthiasm@8: indices = ind2subv(mysize(v), i);