%----------------------------------------------------
% To run: type draw
% To change the problem solved, simply edit the
% functions f(x,y), g(x,y)
%----------------------------------------------------
% Example: to plot the direction field for the system
%
%      x' = 4*x -   y
%      y' = 2*x + 3*y
%
%  change the following:
%
%  function xp = f(x,y)
%           xp = 4*x - y;
%
%  function yp = g(x,y)
%           yp = 2*x - 3*y
%
% then on the matlab command window type
% > draw
%----------------------------------------------------

function draw()
  xmin = -2; xmax = 2;
  ymin = -2; ymax = 2;
  xpts = 21; ypts = 21;
  axis([xmin xmax ymin ymax])
  X1 = linspace(xmin, xmax, xpts); Y1 = linspace(ymin, ymax, ypts);
  XZ = zeros(xpts,1); YZ = zeros(ypts,1);
  figure
  hold on
  pp(@f,@g,X1,Y1,'x','y','Phase Portrait','r',0);
  plot(X1, XZ, 'k-', YZ, Y1, 'k-')
  hold off
  
  function xp = f(x,y)
  %m=size(x);
  % xp = zeros(m);
    xp = 4*x -2*y ;
  
  function yp = g(x,y)
  %m=size(x);
  % yp = ones(m);
    yp = 3*x + y;
    
    
