clear all A=[0 1.1;0.55 0.55] y=zeros(2,20); %build a matrix to store the population data t=zeros(1,20); %build a matrix for total population y(:,1)=[200;0]; %initialize t(1,1)=sum(y(:,1)); %initialize the sum for n=1:19 y(:,n+1)=A*y(:,n); %update with matrix model t(1,n+1)=sum(y(:,n+1)); %update the sum end plot([1:20],y(1,:),'*r',[1:20],y(2,:),'xb',[1:20],t(1,:),'og') legend('juveniles','adults','total')