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