function y = FSM_inc( x, n)
%
% FSM_inc( x, n) - increment x, base n
% where x is an index row vector containing values in the range 1..n
%
% R. Perry, June 2001

c = 1;
y = x;

for i=size(y,2):-1:1

  s = c + y(i);

  if( s > n)
    c = 1;
    y(i) = 1;
  else
    y(i) = s;
    break;
  end

end
