function c = cntabover(c,a,b) % % c = cntabover(c,a,b) % % Returns vector c plus 1 in the last element, up to the value of b. % When overflow in the last element, drop it down to the value of a. % When i=overflow in all elements, drop all elements to the values of a. % % Example: % c = zeros(1,4); % for i=1:17 % c = cntabover(c,0,1) % end i = length(c); while i > 0 if c(i)+1 <= b c(i) = c(i)+1; break else c(i) = a; i=i-1; end end return