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