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