The direction field

The solutions of differential equation (5.2) are curves in the [$ t$ , $ x_1$ , $ x_2$ ]-space, which are given by [$ t$ , $ x_1(t)$ , $ x_2(t)$ ]. The direction field is given by the tangent vectors to the solution curves, i.e., by the vectors [$ 1$ , $ \dot{x}_1(t)$ , $ \dot{x}_2(t)$ ]. Note that you can derive the direction field by means of the right hand side of the differential equation, so you do not need to know the solutions explicitly. In general the explicit dependency on time is omitted and the solutions and the direction field are only plotted in the [$ x_1$ , $ x_2$ ]-plane. So, in fact, the projection on the [$ x_1$ , $ x_2$ ]-plane is being drawn. This plane is also called the phase plane or state space (the state of the system at time $ t$ is given by [$ x_1(t)$ , $ x_2(t)$ ]). The projected solution is also called an integral curve. In a given point [$ x_1(t_0)$ , $ x_2(t_0)$ ] of the state space, the direction vector can be calculated by using the differential equations given. In equation (5.2), the direction vector for the point [$ x_1(t_0)$ , $ x_2(t_0)$ ] = [1,2] is given by [ $ \dot{x}_1(t_0)$ , $ \dot{x}_2(t_0)$ ] = [5*1-2*2, 7*1-4*2] = [1,-1]. The direction field is obtained by determining the direction vector in every point of the state space. To draw a direction field in MATLAB, you first need to indicate the points in the [$ x_1$ , $ x_2$ ]-plane where you want to draw the direction vector. The command:

>> [X,Y] = meshgrid(-1:0.1:1,-2:0.2:2)

produces a matrix $ X$ for which every row is equal to the vector -1:0.1:1 and a matrix $ Y$ for which every column is equal to the vector -2:0.2:2. By combining these matrices elementwise, you obtain grid points [x,y], where $ x$ traverses the vector -1:0.1:1 and $ y$ traverses the vector -2:0.2:2, i.e., the points [$ X_{ij}$ ,$ Y_{ij}$ ]. The matrices $ X$ and $ Y$ can now be used to perform calculations in the grid points. For example, $ U=5X-2Y$ and $ V=7X-4Y$ calculates the components [U,V] of the direction field in every grid point for equation 5.2. To draw the direction field in a number of grid points, you can use the MATLAB command quiver. The command:

>> quiver(X,Y,U,V)

draws the vectors with components [$ U_{ij}$ ,$ V_{ij}$ ] in the points [$ X_{ij}$ ,$ Y_{ij}$ ]. The vectors are scaled automatically. As a consequence of this, sometimes the direction field becomes somewhat unclear. In that case, reducing the number of grid points often clarifies the direction field.

Previous      Next      Up      Contents

Esteur 2010-03-22