% fitz2.m  FitzHugh-Nagumo equations  system of two ODE's
function fitz2
  v = -1.0;
  r = 1.0;
  y(1) = v;
  y(2) = r;
  [t,y] = ode45(@sode,[0 25],[-1 1]);
  axis tight
  figure(1)
  plot(t, y(:,1), '-')
  axis([0 25 -12.5 12.5])
  title('v vs t')
  xlabel('t')
  ylabel('v')
  figure(2)
  plot(t, y(:,2), '-')
  axis([0 25 -12.5 12.5])
  title('r vs t')
  xlabel('t')
  ylabel('r')
  return
  function z = vpf(v, r)
    z = v - v*v*v/3.0 + r;
  return
  end
  function z = rpf(v, r)
    z = -(v - 0.2 - 0.2*r);
  return
  end
  function [ydot] = sode(t, y)
    ydot(1) = vpf(y(1),y(2)); % y(1) is v  y(2) is r
    ydot(2) = rpf(y(1),y(2));
    ydot = ydot'; % column vector
  return
  end
end
