function [num indices] = peaks(v)
  % Finds elements that are "biggest thus far"
  % USAGE:  [num indices] = peaks(v)
  num = 1;          % the first element is always a peak
  maxSoFar = v(1);
  indices = [1];    % peak at index 1 for sure
  
  % check the rest of the vector
  for k = 2:length(v)
      if v(k) > maxSoFar
          maxSoFar = v(k);
          num = num + 1;
          indices = [indices k];
      end
  end
  
  