wolffd@0: function indices = argmin(v) wolffd@0: % ARGMIN Return as a subscript vector the location of the smallest element of a multidimensional array v. wolffd@0: % indices = argmin(v) wolffd@0: % wolffd@0: % Returns the first minimum in the case of ties. wolffd@0: % Example: wolffd@0: % X = [2 8 4; 7 3 9]; wolffd@0: % argmin(X) = [1 1], i.e., row 1 column 1 wolffd@0: wolffd@0: [m i] = min(v(:)); wolffd@0: indices = ind2subv(mysize(v), i); wolffd@0: %indices = ind2subv(size(v), i);