% Script for projection of matrix over time function proj(mat,k,vector,time) % mat = matrix without headings % k = number of stages % vector = population vector at the beginning % time = no. of steps for the projection % Reads the transition matrix fid=fopen(mat,'r'); b=fscanf(fid,'%f',[k,k]); % Transpose the transition matrix - this is due to matlab way of reading b=transpose(b); fclose(fid); % Reads the population vector fid=fopen(vector,'r'); vect=fscanf(fid,'%f',[k,1]); fclose(fid); vec(:,1)=vect; % Calculates no. of individuals in time 1 suma(1)=sum(vec(:,1)); % Projection over time for i=2:time vec(:,i)=b*vec(:,i-1); suma(i)=sum(vec(:,i)); lambda(i)=suma(i)/suma(i-1); end % Plots the result figure; plot(suma); figure; plot(lambda);