algae step

# algae step - n=(m>0& m<=7%Creates another matrix...

This preview shows pages 1–2. Sign up to view the full content.

%Laura Hyde %Laurhyde %Eng101, Section 205, Chad Ohlandt %Project 8 %3/3/08 %algaeStep.m function outputGrid = algaeStep(algaeGrid, foodGrid) %function outputGrid = algaeStep(algaeGrid, foodGrid) %This function models aglae growth and death into the following generation %based on given food levels and algae ages. newAlgaeGrid=zeros(size(algaeGrid)+2); newAlgaeGrid(2:end-1,2:end-1)=algaeGrid; a=size(newAlgaeGrid); i=2:length(a)-1 j=2:length(a)-1 if newAlgaeGrid(i,j)==0 m=newAlgaeGrid(i-1:i+1,j-1:j+1);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n=(m>0 & m<=7); %Creates another matrix around the cell. if((sum(sum(n))>=2) && (foodGrid(i-1,j-1)>75)) newAlgaeGrid(i,j)=1; end %Searches the surrounding cells for algae between the ages of 7 and 1. %If more than two of these cells are found, the main cell is reborn. elseif(newAlgaeGrid(i,j)>0) && (foodGrid(i-1,j-1)>50) newAlgaeGrid(i,j)=newAlgaeGrid(i,j)+1; elseif foodGrid(i-1,j-1)<=50 algaeGrid(i,j)=0; end end end outputGrid=newAlgaeGrid(2:end-1,2:end-1); end...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

algae step - n=(m>0& m<=7%Creates another matrix...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online