function [ C, E_K, E_Na, E_rest, G_K, G_Na, t0, y0, tstop ] = ...
  axon_parameters ( C_user, E_K_user, E_Na_user, E_rest_user, G_K_user, ...
  G_Na_user, t0_user, y0_user, tstop_user )

%*****************************************************************************80
%
%% axon_parameters() returns the parameters for axon_ode().
%
%  Discussion:
%
%    If input values are specified, this resets the default parameters.
%    Otherwise, the output will be the current defaults.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 April 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Alan Hodgkin, Andrew Huxley,
%    A quantitative description of membrane current and its
%    application to conduction and excitation in nerve,
%    The Journal of Physiology,
%    Volume 117, Number 4, pages 500-544, August 1952.
%
%  Input:
%
%    real C_user: the membrane capacity per unit area.
%
%    real E_K_user: the equilibrium potential for potassium.
%
%    real E_Na_user: the equilibrium potential for sodium.
%
%    real E_rest_user: the resting potential.
%
%    real G_K_user: the potassium conductance.
%
%    real G_Na_user: the sodium conductance.
%
%    real t0_user: the initial time.
%
%    real y0_user(4): the values at the initial time of V, N, M, and H.
%
%    real tstop_user: the final time.
%
%  Output:
%
%    real C: the membrane capacity per unit area.
%
%    real E_K: the equilibrium potential for potassium.
%
%    real E_Na: the equilibrium potential for sodium.
%
%    real E_rest: the resting potential.
%
%    real G_K: the potassium conductance.
%
%    real G_Na: the sodium conductance.
%
%    real t0: the initial time.
%
%    real y0(4): the values at the initial time of V, N, M, and H.
%
%    real tstop: the final time.
%
  persistent C_default;
  persistent E_K_default;
  persistent E_Na_default;
  persistent E_rest_default;
  persistent G_K_default;
  persistent G_Na_default;
  persistent t0_default;
  persistent y0_default;
  persistent tstop_default;
%
%  Initialize defaults.
%
  if ( isempty ( C_default ) )
    C_default = 1.0;
  end

  if ( isempty ( E_K_default ) )
    E_K_default = -74.7;
  end

  if ( isempty ( E_Na_default ) )
    E_Na_default = 54.2;
  end

  if ( isempty ( E_rest_default ) )
    E_rest_default = -68.0;
  end

  if ( isempty ( G_K_default ) )
    G_K_default = 12.0;
  end

  if ( isempty ( G_Na_default ) )
    G_Na_default = 30.0;
  end

  if ( isempty ( t0_default ) )
    t0_default = 0.0;
  end

  if ( isempty ( y0_default ) )
    V_init = 0.0;

    alpha_n = 0.01 * ( 10.0 - V_init ) / ( exp ( ( 10.0 - V_init ) / 10.0 ) - 1.0 );
    beta_n = 0.125 * exp ( - V_init / 80.0 );
    n_init = alpha_n / ( alpha_n + beta_n );

    alpha_m = 0.1 * ( 25.0 - V_init ) / ( exp ( ( 25.0 - V_init ) / 10.0 ) - 1.0 );
    beta_m = 4.0 * exp ( - V_init / 18.0 );
    m_init = alpha_m / ( alpha_m + beta_m );

    alpha_h = 0.07 * exp ( - V_init / 20.0 );
    beta_h = 1.0 / ( exp ( ( 30.0 - V_init ) / 10.0 ) + 1.0 );
    h_init = alpha_h / ( alpha_h + beta_h );

    y0_default = [ V_init, n_init, m_init, h_init ];
  end

  if ( isempty ( tstop_default ) )
    tstop_default = 10.0;
  end
%
%  Update defaults if input was supplied.
%
  if ( 1 <= nargin )
    C_default = C_user;
  end

  if ( 2 <= nargin )
    E_K_default = E_K_user;
  end

  if ( 3 <= nargin )
    E_Na_default = E_Na_user;
  end

  if ( 4 <= nargin )
    E_rest_default = E_rest_user;
  end

  if ( 5 <= nargin )
    G_K_default = G_K_user;
  end

  if ( 6 <= nargin )
    G_Na_default = G_Na_user;
  end

  if ( 7 <= nargin )
    t0_default = t0_user;
  end

  if ( 8 <= nargin )
    y0_default = y0_user;
  end

  if ( 9 <= nargin )
    tstop_default = tstop_user;
  end
%
%  Return values.
%
  C = C_default;
  E_K = E_K_default;
  E_Na = E_Na_default;
  E_rest = E_rest_default;
  G_K = G_K_default;
  G_Na = G_Na_default;
  t0 = t0_default;
  y0 = y0_default;
  tstop = tstop_default;

  return
end

