%dirfield  direction field for first order ODE
%   dirfield(func,tval,yval) plots the direction field for the first order
%   ODE given by func, using the grid of t and y values given by the vectors
%   tval and yval. func is either a the name of an inline function of two 
%   variables, or a string with the name of an m-file.
%   Note that func must use ".*", "./", ".^" instead of "*", "/", "^".
function dirfield(func,tval,yval)
[tm,ym]=meshgrid(tval,yval);
yp=feval(func,tm,ym); 
len=sqrt(1+yp.^2);
quiver(tval,yval,1./len,yp./len,.7,'r');
axis tight;
