In: Advanced Math
1) Use MATLAB to solve this differential equation. ??/?? = .25? (1 − ?/4 ) - a
2) Use MATLAB to graph solution curves to this system with several different initial values. Be sure to show at least one solution curve for each of the scenarios found in ??/?? = .25? (1 − ?/4 ) - a ( let a = 0.16)
MATLAB Code:
close all
clear
clc
% Part 1
syms p(t)
a = 0.16;
Dp = diff(p, t); % dp/dt
ODE = Dp == 0.25*p*(1 - p/4) - a; % Given ODE
p_sol = dsolve(ODE); p_sol = p_sol(3); % ODE Solver
fprintf('General Solution, p(t) = '), disp(p_sol)
% Part 2
p_sol_1 = dsolve(ODE, p(0) == 1); % Solve with initial condition
p(0) = 1
t = 0:0.01:50;
p_sol_1_vals = subs(p_sol_1, t); % Evaluate the solution at
different time values
figure, hold on
xlabel('t'), ylabel('p(t)'), title('Solution of ODE using different
initial values')
plot(t, p_sol_1_vals)
p_sol_2 = dsolve(ODE, p(0) == 2); % Initial condition p(0) =
2
p_sol_2_vals = subs(p_sol_2, t);
plot(t, p_sol_2_vals)
p_sol_3 = dsolve(ODE, p(0) == 10); % Initial condition p(0) =
10
p_sol_3_vals = subs(p_sol_3, t);
plot(t, p_sol_3_vals), hold off
legend('p(0) = 1', 'p(0) = 2', 'p(0) = 10')
Output:
General Solution, p(t) = (4*exp(60*C2 - (3*t)/20) - 16)/(5*(exp(60*C2 - (3*t)/20) - 1))
Plot: