MATLAB Tutor
Part 13: Direction
fields
 MATLAB does not have a builtin
command to plot direction fields. An mfile that provides a function for this purpose
called "slpfield" is provided for every module that needs direction fields.
If you downloaded
the package of mfiles in Part 11 of this tutorial, this function is available to
you, provided the file slpfield.m is in your working directory or on MATLAB's path.
If you have not yet downloaded the package, go back to Part 11 and do it now.
 In order to make the plot of the direction field, the "slpfield" function
must be provided a function called "dfun" which gives the right hand side
of the differential equation.
Use a text editor to edit the file dfun.m (provided in the same package as
slpfield.m) so that the righthandside function is y.*(1y). (The period
after the y is important.)

Assuming you have the correct dfun.m file, we can now plot the vector field on
the interval 2 < t < 2 and 0.5 < y < 2.
Enter:
slpfield(2, 2, 0.5, 2)
hold on %holds the plot
 Now plot the function h
from Part 12 on top of the slope field plot. We use the same limits on t.
Enter:
ezplot( h, [2,2] )
axis( [2, 2, 0.5, 2] )
Does this solution look like it fits
the direction field?
 Adjust
the horizontal ranges and redraw the direction field and the solution plot
so that you can see the solution
function h approach equilibrium. If necessary, enlarge the picture
so you can see more detail. Are you convinced that the symbolic solution
h fits the direction field?
 Edit the dfun.m file in order to generate
direction fields over appropriate ranges of the variables for the following
differential equations:

dy/dt = y^{2}

dy/dt = ty + t