Please provide the MATLAB code for parts af Consider the pre
Please provide the MATLAB code for parts a-f.
Consider the predator-prey model dx/dt = x(4 - 3y) dy/dt = y (x - 2) in which x greaterthanorequalto 0 represents the population of the prey and y greaterthanorequalto 0 represents the population of the predators. Find all critical points of the system. At each critical point, calculate the corresponding linear system and find the eigenvalues of the coefficient matrix; then identify the type and stability of the critical point. Plot the vector field on a region small enough to distinguish the critical points but large enough to judge the possible solution behaviors away from the critical points. Use several initial data points (x_0, y_0) in the first quadrant to draw a phase portrait for the system. Identify the direction of increasing t on the trajectories you obtain. Use the information from parts (a) and (b) to choose a representative sample of initial conditions. Then combine the vector field and phase portrait on a single graph. Explain from your phase portrait how the populations vary over time for initial data close to the unique critical point inside the first quadrant. What happens for initial data far from this critical point? Suppose the initial state of the population is given by x(0) = 1, y(0) = 1. Find the state of the population at t = 1, 2, 3, 4, 5. Estimate to two decimal places the period of the solution curve that starts at (1, 1).Solution
% set up Predator Prey dynamics
f = @( t , x ) [ 4 x ( 1 ) 3x ( 1 ) . x ( 2 ) ;2x ( 2 )+x ( 1 ) . x ( 2 ) ] ;
% final time
T = 1.5 ;
% stepsize
h =.1;
%find averages
x\'= 2/1 ;
y\' = 4/3 ;
%pick IC so MU is small
x0 = [ 0.2 ; 8 ] ;
% number o f steps
N = c e i l (T/h ) ;
%find RK 4 approximate solution
[ ht , r k ] = FixedRK ( f , 0 , x0 , h , 4 ,N) ;
% set X and Y
X = rk ( 1 , : ) ;
Y = rk ( 2 , : ) ;
% get x1 and x2 from our bounding box argumen t
% using min and max o f X
x1 = min (X)
x2 = max (X) ;
% get y1 and y2 f rom our bounding box argumen t
% using min and max o f Y
y1 = min (Y);
y2 = max (Y) ;
% plot x1
p l o t ( [ x1 x1 ] , [ y1 y2 ] , ’ b ’ ) ;
% plot x2
p l o t ( [ x2 x2 ] , [ y1 y2 ] , ’ g ’ ) ;
% plot y1
p l o t ( [ x1 x2 ] , [ y1 y1 ] , ’ r ’ ) ;
%plot y1
p l o t ( [ x1 x2 ] , [ y2 y2 ] , ’ m’ ) ;
% plotY vs X
p l o t (X , Y, ’k ’ ) ;
% s e t l e g e n d
le g e n d ( ’ x1 ’ , ’ x2 ’ , ’ y1 ’ , ’ y2 ’ , ’ y v s x ’ , ’ L o c a t i o n ’ , ’ Best ’ ) ;
hold off;

