% Filename: EcoSuccessionTable.m
% M-file to
% - Print out a table showing landscape structure over time

% Enter the transfer matrix
T = [ 0.94 0.02 0.01 
      0.05 0.86 0.06
      0.01 0.12 0.93 ];
  
% Enter the initial state
x0 = [ 1 ; 0 ; 0 ];
  
% Print header for table
fprintf(' t      u      s      d\n')
fprintf('-------------------------\n')

% Fill in table using a for loop
for t = [1 2 3 4 5 10 20 30 40 50 100 200]  % array of times
   x = T^t * x0;            % matrix multiplication
   u = x(1,1);              % get u value for this time step
   s = x(2,1);              % get s value for this time step
   d = x(3,1);              % get d value for this time step
   fprintf('%3d  %5.3f  %5.3f  %5.3f\n',t,u,s,d)  % print it all out
end