Question: ANSWER WITH MATLAB CODE Consider an experiment where bacteria are grown on a plate divided into an R-by-C grid. Let matrix M (with R rows,

ANSWER WITH MATLAB CODE

Consider an experiment where bacteria are grown on a plate divided into an R-by-C grid. Let matrix M (with R rows, C columns) represent the number of bacteria in each block of this grid. When a drop of antibiotic is delivered to a specific block at row x and column y, it kills all of the bacteria on that block and half of the bacteria in all of the neighboring blocks. The figure below shows an example of a plate composed of a 4-by-4 grid, where the numbers represent bacteria count in each block. After the antibiotic is delivered to the block at 2nd row and 3th column, it kills all of the 10 bacteria on that block and half of the bacteria in neighboring blocks: (2+3+13+11+8+7+6+12)/2=31; killing a total of 41 bacteria. Write a function remainingbacteria(M,x,y) that returns the total number of bacteria killed and the new matrix with the remaining number of bacteria in each block.

THE CORRECT ANSWER WILL RETURN THE FOLLOWING OUTPUTS EXACTLY:

>> [kills,newgrid]= remainingbacteria([16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1],2,3) kills = 41 newgrid = 16.0000 1.0000 1.5000 6.5000 5.0000 5.5000 0 4.0000 9.0000 3.5000 3.0000 6.0000 4.0000 14.0000 15.0000 1.0000 >> [kills,newgrid]= remainingbacteria([16 2 3 13; 5 11 10 8],1,4) kills = 23.5000 newgrid = 16.0000 2.0000 1.5000 0 5.0000 11.0000 5.0000 4.0000 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!