Using MatLab, complete the following:
%%Matlab code for Midpoint method
clear all
close all
%function for solving ODE using midpoint method
fun=@(t,p) ((1/60)-((3*t)./50)).*p-1;
t(1)=0;p(1)=9; %initial
conditions
t_in=t(1); %Initial
t
t_max=20; %Final
t
%Midpoint iterations
h=0.01;
n=(t_max-t_in)/h;
for i=1:n
k1=h*fun(t(i),p(i));
k2=h*fun(t(i)+(1/2)*h,p(i)+(1/2)*k1);
t(i+1)=t_in+i*h;
p(i+1)=double(p(i)+k2);
end
hold on
plot(t,p,'linewidth',2)
fprintf('For step size h=%2.2f and p(0)=9\n
',h)
fprintf('\n\tAt t=%f value of
p=%f.\n\n',t(end),p(end))
clear t; clear p;
t(1)=0;p(1)=50; %initial
conditions
t_in=t(1); %Initial
t
t_max=20; %Final
t
%Midpoint iterations
h=0.01;
n=(t_max-t_in)/h;
for i=1:n
k1=h*fun(t(i),p(i));
k2=h*fun(t(i)+(1/2)*h,p(i)+(1/2)*k1);
t(i+1)=t_in+i*h;
p(i+1)=double(p(i)+k2);
end
fprintf('For step size h=%2.2f and p(0)=20\n
',h)
fprintf('\n\tAt t=%f value of
p=%f.\n\n',t(end),p(end))
plot(t,p,'linewidth',2)
box on
xlabel('time t')
ylabel('p(t)')
title('p(t) vs. t plot using midpoint
method')
legend('p(0)=9','p(0)=50')
%%%%%%%%%%%%%%%%%% End of Code
%%%%%%%%%%%%%%%%%%
Using MatLab, complete the following: A model for extermination of a roach population in an area p(t) is based on the assumption that their growth rate decreases over time at a rate of 3/50 per day,...