%% Question 2 - Logistic equation
%
% Using ode23 to solve the logistic equtions with various initial
% conditions and two time intervals: $[0,3]$ and $[0,-1]$.
%
% We plot both time intervals for a single initial condition on the
% same plot for convenience

%% $x_0=\frac12$
[t1,x1] = ode23(@logistic, [0,3], 0.5);
[t2,x2] = ode23(@logistic, [0,-1], 0.5);
plot(t1, x1, t2, x2);
xlabel('t')
ylabel('x')

%% $x_0=\frac32$
[t1,x1] = ode23(@logistic, [0,3], 1.5);
[t2,x2] = ode23(@logistic, [0,-1], 1.5);
plot(t1, x1, t2, x2);
xlabel('t')
ylabel('x')

%% $x_0=1$
[t1,x1] = ode23(@logistic, [0,3], 1);
[t2,x2] = ode23(@logistic, [0,-1], 1);
plot(t1, x1, t2, x2);
xlabel('t')
ylabel('x')

%% $x_0=-\frac1{20}$
[t1,x1] = ode23(@logistic, [0,3], -0.05);
[t2,x2] = ode23(@logistic, [0,-1], -0.05);
plot(t1, x1, t2, x2);
xlabel('t')
ylabel('x')