% iterate.m		
% iterate a function of an initial value x0
% N times. 
%
% mu = function parameter
% x0 = initial value of x
% N = number of iterations
% i = running index 
% x = iterated values
%
% Usage: [i,x] = iterate(mu, x0, N); 

function [i,x] = iterate(mu, x0, N)     %function declaration

i = 1:N;				%i is an index vector numbered from 1 to N

x = zeros(1,N);			% initialize x, which is a vector of length N, or a 1xN matrix.

y = x0;
for k = 1:N				% iterate x with function mu*x N times and store value in x(k)
  x(k) = y;             
  y = mu*y;
end 					
