function flow2D_ode() % % Draw the flow of a 2D system % close all Define the x and y sets xmin = -1; xmax = +4; x = linspace(xmin, xmax, nPoints); ymin = -2; ymax = +3; y = linspace(ymin, ymax, nPoints); [X, Y] = meshgrid(x, y); Draw the flow figure quiver(X, Y, dX, dY, 'b') Draw the nullclines nPoints = 100; % Increase the resolution for the nullclines x = linspace(xmin, xmax, nPoints); plot(x, 2*x-(1/2)*x.^2, 'k--') plot(x, (1/2)*x, 'k--') Draw the solution over time figure plot(t, x) hold on plot(t, y) xlabel('t') legend('x(t)', 'y(t)')endfunction du = f(t, u) x = u(1); y = u(2); dx = -4*x + x^2 + 2*y; dy = x - 2*y; du = [dx; dy];end