% FGRAB = Fast Growth, Replacement and Burn Matrices % % function [G,R,B] = fgrab(time, control, growth, replace, death) % % 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] = fgrab(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 using matrix mutliplication g = growth(I,:); G = diag([1-g,1]) + [[zeros(1,length(g+1));diag(g)],zeros(length(g)+1,1)]; % Fill in replacement matrix R = zeros(l,l); R(1,:) = replace(J,:); % Fill in burn matrix B = diag(burn(K,:));