function indices = argmax(v)
% ARGMAX Return as a subscript vector the location of the largest element of a multidimensional array v.
% indices = argmax(v)
%
% Returns the first maximum in the case of ties.

[m i] = max(v(:));
if isvector(v)
  indices = i;
else
  indices = ind2subv(size(v), i);
end
