I am working on two equations. The logistic equation $$x'_i=r_i x_i \left(1-\frac{x_i}{K_i}\right) \tag{1}$$ and a two-species competition model $$ \begin{aligned} x'_1 &= r_1 x_1 \left(1-\frac{x_1}{K_1}\right) - \alpha_1 x_1 x_2\\ x'_2 &= r_2 x_2 \left(1-\frac{x_2}{K_2}\right) - \alpha_2 x_2 x_1 \end{aligned} \tag{2} $$ My assignment says
Write two Matlab codes: one that can solve a scalar ODE and one that can solve a system of two ODEs. Let both programs to choose several initial data points and draw corresponding integral curves both as functions of time. In the case of the system of two equations the code must draw trajectories of $(x_1(t); x_2(t))$ in the phase plane of $(x_1; x_2)$ in a separate figure.
Can I use quiver to draw a phase plot for equation $(2)$?
So does quiver plot it as a function of time?
xdom = linspace(-5,5,51);
ydom = linspace(-5,5,51);
[X,Y] = meshgrid(xdom,ydom); % generate mesh of domain
U = equation here for i=1; % dx/dt
V = equation here for i=2; % dx/dt
quiver(X,Y,U,V)
What changes do I need to make it run for this equation? Any help is appreciated. Thank you.
In both cases, the question asks to compute trajectories numerically e.g. using
ode45for several initial data. Then, we are asked to plot the numerical solutions $(t; x_1(t))$, $(t; x_2(t))$ so-obtained with respect to time. For the competition model, it is possible to superimpose aquiverstream plot with such trajectories $(x_1(t); x_2(t))$ in the phase diagram. Here is a runable Matlab script:Output: