function california_migration_scalar_test ( )

%*****************************************************************************80
%
%% california_migration_scalar_test() tests california_migration_scalar().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 January 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'california_migration_scalar_test():\n' );
  fprintf ( 1, '  Test california_migration_scalar()\n.' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Year     CA Pop     US pop      Total\n' );
  fprintf ( 1, '\n' );

  m = 21;
  ca = zeros ( 1, m );
  us = zeros ( 1, m );
  year = linspace ( 1960, 1960 + m - 1, m );

  for i = 1 : m

    if ( year(i) == 1960 )
      ca(i) =  16000000;
      us(i) = 164000000;
    else
      [ ca(i), us(i) ] = california_migration_scalar ( ca(i-1), us(i-1) );
    end

    fprintf ( '  %4d  %9.0f  %9.0f  %9.0f\n', ...
      year(i), ca(i), us(i), ca(i) + us(i) );

  end

  clf ( );
  hold ( 'on' );
    plot ( year, ca, 'r', 'Linewidth', 3 );
    plot ( year, us, 'b', 'Linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Year -->' );
  ylabel ( '<-- Population -->' );
  title ( 'California migration scalar' );
  legend ( 'CA', 'US' );
  filename = 'california_migration_scalar.png';
  print ( '-dpng', filename );     
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );

  return
end

