Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER WITH MATLAB CODE CAPABLE OF GENERATING PLOT Loops. In the Lotka Volterra predator-prey model, the changes in the predator population y and the prey

ANSWER WITH MATLAB CODE CAPABLE OF GENERATING PLOT

Loops. In the Lotka Volterra predator-prey model, the changes in the predator population y and the prey population x are described by the following equations:

xt=xt+1xt=axtbxtyt

yt=yt+1yt=cxtytdyt

Write a function simulatepredatorprey(x,y, a,b,c,d, T) that takes in the initial population sizes of x and y and simulates the model with the input parameters, for T discrete time steps (in years), updating the population sizes after each time step. For each time step, calculate the number of predator & prey from the population sizes of the previous year using the difference equations above. Your function should return the history of the population sizes as a 2-row matrix (first row containing the history of x and second row containing the history of y), starting with the initial population sizes in the first column, and with each additional column containing the population sizes of x and y at that time step. Your function should also plot the population the predator and the prey over time. Predator and prey plots should use different line and marker styles. The axes should be labeled and the figure should contain a legend. Assume the time steps are given in years and the population sizes are given in thousands.

>> disp(simulatepredatorprey(10,20, 0.1, 0.01, 0.01, 0.2, 1)) 10 9 20 18 >> disp(simulatepredatorprey(10,20, 0.1, 0.01, 0.01, 0.2, 5)) 10.0000 9.0000 8.2800 7.7815 7.4592 7.2791 20.0000 18.0000 16.0200 14.1425 12.4145 10.8576 

The image below was generated for a different test case than the ones shown above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How can speakers manage speaking anxiety?

Answered: 1 week ago