clear all p=.75; %fraction of cells that survive each reproduction generation_end=100; %predict up to this generation in the future K=2000; %reproduction capacity %Define list (vector) nlist, where nlist(t) is number of cells per generation %Dummy list -- all zeros nlist=zeros(1,generation_end); nlist(1)=1000; %initial number of cells (generation 0) for t=2:generation_end nlist(t)=4*nlist(t-1)*p*(1-nlist(t-1)/K) ; end %WAY 1 which_entry_to_update=1 for t=1:generation_end if nlist(t)>1300 list_of_times_over_limit(which_entry_to_update)=t ; %next I say: update the NEXT entry down the list next time which_entry_to_update=which_entry_to_update+1; end end list_of_times_over_limit %WAY 3 %list_of_times_over_limit=find(nlist>1300) tlist=1:generation_end; figure plot(tlist,nlist,'.','MarkerSize',24) ylabel('n(t)','FontSize',20) xlabel('t','FontSize',20) set(gca,'FontSize',20)