function california_migration_matrix_test ( )

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

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

  m = 21;
  pop = zeros ( m, 2 );
  year = linspace ( 1960, 1960 + m - 1, m );

  for i = 1 : 21

    if ( i == 1 )
      pop(1,1) =  16000000;
      pop(1,2) = 164000000;
    else
      pop(i,1:2) = california_migration_matrix ( pop(i-1,1:2) );
    end

    fprintf ( 1, '  %4d  %9.0f  %9.0f  %9.0f\n', ...
      year(i), pop(i,1), pop(i,2), pop(i,1) + pop(i,2) );

  end

  clf ( );
  hold ( 'on' );
    plot ( year, pop(:,1), 'linewidth', 3 );
    plot ( year, pop(:,2), 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Year -->' );
  ylabel ( '<-- Population -->' );
  title ( 'California population matrix' );
  legend ( 'CA', 'US' );
  filename = 'california_migration_matrix.png';
  print ( '-dpng', filename );  
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  close ( );

  return
end

