Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider an experiment where ants are placed on a rectangular board of height R

ID: 3841344 • Letter: C

Question

Consider an experiment where ants are placed on a rectangular board of height R inches and width C inches and are allowed to move on the board. Let us represent the number of ants on one inch-square segments of the board by the matrix m. The figure below shows an example of a 3-by-4 board. After one minute, for any given segment, 1/9th of the ants stay on that segment, whereas the remaining 8/9th of them move to the neighboring cells (up/down/left/right and diagonals). This means that for the ants on the segments along the edges of the board, some of the ants move off the board. Write a function simulateants2dallway(m,T) that takes a matrix m and returns the number of ants on the segments of the board after T minutes. For simplicity, assume that the number of ants in a segment does not have to be a whole integer. Assume the time length T is an integer. If T is not given, use T=1.

Explanation / Answer

Answer:

The function is written as below :

>> disp( simulateants2d( [8 0 0 4; 0 0 10 0; 0 0 0 0] ) )
0            2.0000            3.5000    0
2.0000    2.5000             0               3.5000
0                  0                 2.5000            0
>> disp( simulateants2d( [8 0 0 4; 0 0 10 0; 0 0 0 0], 2 ) )
1.0000                     1.5000       0.5000        1.7500
0.6250                     1.0000         3.0000      0
0.5000                     1.2500         0                 1.5000