function random_walk_1d_plot ( step_num, walk_num )

%*****************************************************************************80
%
%% random_walk_1d_plot() plots 1 or more random walks in 1D.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 November 2009
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer STEP_NUM, the number of steps to take in one test.
%
%    integer WALK_NUM, the number of walks.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'random_walk_1d_plot():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Simulate and plot WALK_NUM random walks of STEP_NUM steps each.\n' );

%
%  Clear the plotting frame.
%
  clf ( );

  plot ( [0, step_num], [0, 0], 'r-', 'LineWidth', 2 );
  hold ( 'on' );

  for walk = 1 : walk_num

    time = 0 : step_num;
    x = zeros(step_num+1,1);
%
%  Take a walk of STEP_NUM random +1 or -1 steps.
%
    for step = 1 : step_num

      r = rand ( );
%
%  Take the step.
%
      if ( r <= 0.5 )
        x(step+1) = x(step) - 1;
      else
        x(step+1) = x(step) + 1;
      end

    end
%
%  Plot the results.
%
    plot ( time, x, 'LineWidth', 1 );

    title_string = sprintf ( '1D Random Walk - %d walks, %d steps', walk, step_num );
    title ( title_string );
    xlabel ( 'Time' );
    ylabel ( 'Average X(T)' );

    pause ( 5 );

  end

  hold ( 'off' );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'random_walk_1d_plot():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
