Insect population An insect population doubles every generation. Write a while loop that iterates numGeneration times. Inside the while loop, write a statement that doubles currentPopulation in each iteration of the while loop. Function Save Reset MATLAB DocumentationOpens in new tab function currentPopulation = CalculatePopulation(numGeneration, initialPopulation) % numGeneration: Number of times the population is doubled % currentPopulation: Starting population value i = 1; % Loop variable counts number of iterations currentPopulation = initialPopulation; % Write a while loop that iterates numGeneration times while ( 0 ) % Write a statment that doubles currentPopulation in % each iteration of the while loop % Hint: Do not forget to update the loop variable end end 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Code to call your function

Respuesta :

Answer:

function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)

    i = 1;

    currentPopulation = initialPopulation;

    while(i <= numGeneration)

         currentPopulation = 2* currentPopulation;

         i= i+1;

    end

end

Explanation:

  • Assign 1 to i as an initial loop value .
  • Assign  initialPopulation to currentPopulation  variable.
  • Run the while loop until i is less than numGeneration.
  • Inside the while loop, double the currentPopulation  variable.
  • Inside the while loop, Increment the i variable also.

In this exercise we have to use the knowledge of computational language in python to describe a code, like this:

The code can be found in the attached image.

To make it easier the code can be found below as:

function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)

   i = 1;

   currentPopulation = initialPopulation;

   while(i <= numGeneration)

        currentPopulation = 2* currentPopulation;

        i= i+1;

   end

end

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira