% % decide whether to move east, move, mark as having moved, and update boundaries move( 2:d+1, 1:d+1 ) = fish( 2:d+1, 1:d+1 ) & ... ( direction( 2:d+1, 1:d+1 ) == 1) & ( ~fish( 2:d+1, 2:d+2 ) ); fish(2:d+1,2:d+1)= ( fish(2:d+1,2:d+1) & (~move(2:d+1,2:d+1) ) ) | ... move(2:d+1,1:d); direction(2:d+1,2:d+1) = direction(2:d+1,2:d+1) .* ( 1-move(2:d+1,1:d)); updateboundaries; if dbug == 1, subplot(221), plotfish; disp(['i= ',num2str(i),' just moved east']), keyboard, end