function grazing_ode45 ( )

%*****************************************************************************80
%
%% grazing_ode45() solves grazing_ode() using ode45().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'grazing_ode45():\n' );
  fprintf ( 1, '  Solve grazing_ode() using ode45().\n' );

  [ a, c1, c2, d1, d2, k, r1, t0, y0, tstop ] = grazing_parameters ( );

  f = @grazing_deriv;
  tspan = [ t0, tstop ];

  [ t, y ] = ode45 ( f, tspan, y0 );

  n = size ( t, 1 );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of variable size steps = %d\n', n );
%
%  Plot the solution.
%
  figure ( 1 );
  hold ( 'on' );
  plot ( t, y(:,1), 'g', 'LineWidth', 2 );
  plot ( t, y(:,2), 'r', 'LineWidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( 'Time' );
  ylabel ( 'Population' );
  title ( 'grazing\_ode(): ode45(), time plot' )
  filename = 'grazing_ode45_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 2 );
  plot ( y(:,1), y(:,2), 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( 'Grass' );
  ylabel ( 'Grass eaters' );
  title ( 'grazing\_ode(): ode45(), phase plot' )
  filename = 'grazing_ode45_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

