Question

This exercise is to be completed as a binary exercise. It is taken from Chapra Section 28.2. Note that exercises like these m
0 0
Add a comment Improve this question Transcribed image text
Answer #1

% First write this code and save in same folder as other code

function dydt = myode(t,y)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
a=1.2;
b=0.6;
c=0.8;
d=0.3;
dydt = zeros(2,1);
dydt(1) = (a*y(1)) -(b*y(1)*y(2));
dydt(2) =(-c*y(2)) +(d*y(1)*y(2));

clc;clear all;close all;
%%
ft = [0 20];
x0=2;
y0=1;
[t,f] = ode45(@(t,y) myode(t,y), ft,[x0,y0]);
x=f(:, 1) ;
y=f(:, 2);
plot(t,x,'r',t,y,'b')
xlabel('Time t');
ylabel('Solution x and y');
legend('Prey','Predator')


for n=1: length(x)
if (x(n)-y(n)>=0)&&(x(n)-y(n)<=0.06)
disp('when Preys support predators is ')
disp(x(n))
end
end
for n=1: length (x)
if y(n) ==max(y)
disp('Preys when predators are at max ')
disp(x(n))
end
end

5.5 Prey Predator 5 4.5 4 3.5 3 2 1.5 0.5 0 2 468 10 12 1416 18 20 Time tCommand Window New to MATLAB? See resources for Getting Started when Preys support predators is 3.5458 Preys when predators a

Add a comment
Know the answer?
Add Answer to:
This exercise is to be completed as a binary exercise. It is taken from Chapra Section 28.2. Note...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT