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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started