Question
Assume that the grouse play the same role as the rabbits. Assume that food supply for both rabbits and grouse is unlimited. Assume that foxes
Assume that the grouse play the same role as the rabbits.
Assume that food supply for both rabbits and grouse is
unlimited.
Assume that foxes do not prefer one prey over the other.
Fox population factors Fox birth rate:BRF (frac/fox/year) Fox death rate:DRF Fox growth rate:GRF = BRF-DRF
Rabbit population factors Rabbit birth rate:BRR Rabbit death rate:DRR Rabbit growth rate: GRF = BRR-DRR
g(t):population of grouse BRG,birth rate of grouse DRG,death rate of grouse EFG,effect of fox upon grouse EGF, effect of grouse upon fox
So,in MatLab what I am assuming is that the for loop I made either the dr, df or dg equation is incorrect because the parameters, initconds, timedata, and the output of the function is given so somewhere in the for loop is incorrect so I need help:
FUNCTION
function [ rvec,gvec,fvec ]= PredatorPrey_4_fcn(parameters,timedata,initconds)
% Copy and paste your code here
%Parameters 1-7
GRR=parameters(1);
EFR=parameters(2);
GRG=parameters(3);
ERG=parameters(4);
GRF=parameters(5);
ERF=parameters(6);
EGF=parameters(7);
%Initconds 1-3
rinit1=initconds(1);
finit1=initconds(2);
ginit1=initconds(3);
%timedata 1-3
tinit=timedata(1);
tfinal=timedata(2);
delt=timedata(3);
t=tinit:delt:tfinal;
%output
rvec=rinit1;
fvec=finit1;
gvec=ginit1;
%create for loop for fox/rabbit population (THIS PART I BELIEVE IS WRONG)
for i=1:length(t)-1
dr=(GRR*rvec(i)-((EFR*fvec(i))*rvec(i)));
df=(GRF*fvec(i)+((ERF*rvec(i))*fvec(i))+(EGF*gvec(i))*fvec(i));
dg=(GRG*gvec(i)-((ERG*fvec(i))*gvec(i)));
rvec(i+1)=rvec(i)+dr*delt;
fvec(i+1)=fvec(i)+df*delt;
gvec(i+1)=gvec(i)+dg*delt;
end
rvec=rvec'
fvec=fvec'
gvec=gvec'
end
CODE TO CALL YOUR FUNCTION
% Below is a script that will execute and plot your function for some given sample parameters.
% Try adjusting the parameters to see if the model behaves as you would predict
GRR4= 0.4;
EFR4= 0.032;
GRG4= 0.4;
EFG4= 0.032;
GRF4= -1.0;
ERF4= 0.02;
EGF4= 0.02;
tinit= 0.;
tfinal= 60.;
delt= 0.05;
rinit4= 35;
ginit4= 25;
finit4= 20;
parameters4= [GRR4,EFR4,GRG4,EFG4,GRF4,ERF4,EGF4];
initconds4= [rinit4,ginit4,finit4];
timedata4= [tinit,tfinal,delt];
[rvec,gvec,fvec]= PredatorPrey_4_fcn(parameters4,timedata4,initconds4);
hold on
plot(rvec)
plot(fvec,'r')
plot(gvec,'g')
xlabel('step #')
ylabel('population')
legend('rvec','fvec','gvec')
hold off
Below is the original correct code that only involved foxes and rabbits, not adding geese
FUNCTION
function [rvec,fvec]=PredatorPrey_1_fcn(parameters,initconds,timedata)
% Copy and paste your code here
%Parameters 1-4
GRR=parameters(1);
EFR=parameters(2);
GRF=parameters(3);
ERF=parameters(4);
%Initconds 1 & 2
rinit1=initconds(1);
finit1=initconds(2);
%timedata 1-3
tinit=timedata(1);
tfinal=timedata(2);
delt=timedata(3);
t=tinit:delt:tfinal;
%output
rvec=rinit1;
fvec=finit1;
%create for loop for fox/rabbit population
for i=1:length(t)-1
dr=(GRR*rvec(i)-((EFR*fvec(i))*rvec(i)));
df=(GRF*fvec(i)+((ERF*rvec(i))*fvec(i)));
rvec(i+1)=rvec(i)+dr*delt;
fvec(i+1)=fvec(i)+df*delt;
end
rvec=rvec'
fvec=fvec'
end
CODE TO CALL YOUR FUNCTION
% Below is a script that will execute and plot your function for some given sample parameters.
% Try adjusting the parameters to see if the model behaves as you would predict
GRR= 0.4;
EFR= 0.032;
GRF= -1.0;
ERF= 0.02;
tinit= 0.;
tfinal= 60.;
delt= 0.05;
rinit1= 30;
finit1= 20;
parameters1= [GRR,EFR,GRF,ERF];
timedata1= [tinit,tfinal,delt];
initconds1= [rinit1,finit1];
[rvec,fvec]= PredatorPrey_1_fcn(parameters1,initconds1,timedata1);
hold on
plot(rvec)
plot(fvec,'r')
xlabel('step #')
ylabel('population')
legend('rvec','fvec')
hold off
(Remember to be done in MATLAB language)
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