Question
In this problem, you are expected to generate a graphical output . Solve it in MATLAB Loops. In the Lotka Volterra predator-prey model, the changes
In this problem, you are expected to generate a graphical output . Solve it in MATLAB 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
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