function circadian_ode23 ( )

%*****************************************************************************80
%
%% circadian_ode23() uses ode23() to solve circadian_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 July 2026
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'circadian_ode23()\n' );
  fprintf ( 1, '  circadian_ode() solved by ode23().\n' );
%
%  Get the parameter values.
%
  [ kappa1, kappa2, kappas, ...
    k1, k2, k3, k4, kd, ki, km, ...
    n, nud, num, nus, ...
    v1, v2, v3, v4, ... 
    t0, u0, tstop ] = circadian_parameters ( );

  f = @ circadian_deriv;
  tspan = [ t0, tstop ];
%
%  Compute the approximate solution at equally spaced times.
%
  [ t, u ] = ode23 ( f, tspan, u0 );

  t_num = size ( t, 1 );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of variable size steps = %d\n', t_num );
%
%  Separate the data.
%
  M  = u(:,1);
  P0 = u(:,2);
  P1 = u(:,3);
  P2 = u(:,4);
  PN = u(:,5);

  PT = u(:,2) + u(:,3) + u(:,4) + u(:,5);
%
%  Plot time series.
%
  clf ( );
  hold ( 'on' );
    plot ( t, M,  'r.', 'markersize', 15 );
    plot ( t, P0, 'g.', 'markersize', 15 );
    plot ( t, P1, 'b.', 'markersize', 15 );
    plot ( t, P2, 'c.', 'markersize', 15 );
    plot ( t, PN, 'm.', 'markersize', 15 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- T -->' );
  ylabel ( '<-- Y -->' );
  title ( 'circadian\_ode() M, P0, P1, P2, PN' );
  legend ( 'M', 'P0', 'P1', 'P2', 'PN' );
  filename = 'circadian_time.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s\n', filename );
%
%  Plot phase plane.
%
  clf ( );
  plot ( PT, M, 'r', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- PT -->' );
  ylabel ( '<-- M -->' );
  title ( 'circadian\_ode() phase plane' );
  filename = 'circadian_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s\n', filename );

  return
end

