% GRAB = Growth, Replacement and Burn Matrices % % function [G,R,B] = grab(t, c, growth, replace, burn) % % This function grabs the growth, replacement and death information for a given year % time = year you are considering % control = frequency of control burning in years % growth = the matrix which contains the growth information for the tree population % replace = the matrix which contains the reproduction information for the tree population % death = the matrix which contains the death information for the tree population % function [G,R,B] = grab(t, c, growth, replace, burn) % Find sizes of matrices [M,N] = size(growth); [L,l] = size(replace); [m,n] = size(burn); % Check matrice lengths if N ~= l - 1 | n ~= l, error = 'fgrab: Matricies are not of the same length. N = L - 1 and n = L' N n l break; end % Determine which year in the cycle the growth and replacement matrices will be for % % For growth matrix if mod(t,c) >= M I = M; else I = mod(t,c) + 1; end % For replacement matrix if mod(t,c) >= L J = L; else J = mod(t,c) + 1; end % For burn/death matrix if mod(t,c) >= m K = m; else K = mod(t,c) + 1; end % Fill in growth matrix count = 1; for Pg = 1 : N, G(count,Pg) = 1 - growth(I,Pg); G(count+1,Pg) = growth(I,Pg); count = count + 1; end G(N+1,N+1) = 1; % Fill in replacement matrix count = 1; for Pri = 1 : l, for Prj = 1 : l, if Pri == 1 R(Pri,Prj) = replace(J,Prj); else R(Pri,Prj) = 0; end end end % Fill in burn matrix count = 1; for Pbi = 1 : n, for Pbj = 1 : n, if Pbi == Pbj B(Pbi,Pbj) = burn(K,Pbj); else B(Pbi,Pbj) = 0; end end end