function correlation_heat_map ( )

%*****************************************************************************80
%
%% correlation_heat_map() draws a heat map of a correlation matrix.
%
%  Discussion:
%
%    The matrix C is symmetric, with values between -1 (highest anticorrelation)
%    and +1 (highest correlation), with 1's on the diagonal.
%
%    In this example, all the entries are positive.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 April 2025
%
%  Author:
%
%    John Burkardt
%
  timestamp ( );

  fprintf ( 1, '' );
  fprintf ( 1, 'correlation_heat_map():\n' );
  fprintf ( 1, '  MATLAB/Octave version: %s\n', version ( ) );
  fprintf ( 1, '  Make a heat map from a correlation matrix C(1:n,1:n)\n' );
%
%  Set the data.
%
  C = [ ...
    1.00, 0.85, 0.81, 0.86, 0.47, 0.40, 0.30, 0.38 ; ...
    0.85, 1.00, 0.88, 0.83, 0.38, 0.33, 0.28, 0.41 ; ...
    0.81, 0.88, 1.00, 0.80, 0.38, 0.32, 0.24, 0.34 ; ...
    0.86, 0.83, 0.80, 1.00, 0.44, 0.33, 0.33, 0.36 ; ...
    0.47, 0.38, 0.38, 0.44, 1.00, 0.76, 0.73, 0.63 ; ...
    0.40, 0.33, 0.32, 0.33, 0.76, 1.00, 0.58, 0.58 ; ...
    0.30, 0.28, 0.24, 0.33, 0.73, 0.58, 1.00, 0.54 ; ...
    0.38, 0.41, 0.34, 0.36, 0.63, 0.58, 0.54, 1.00 ];
%
%  Form the figure.
%  The huge InitialMagnification value is necessary, since as far
%  as imshow() is concerned, an 8x8 array is displayed as an 8x8 pixel image...
%
  imshow ( C, colormap = hot, InitialMagnification = 10000 );
  colorbar ( );
  title ( 'Heat map of a correlation matrix' );
  filename = 'correlation_heat_map.png';
  print ( '-dpng', filename );
  fprintf ( 1, '' );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '' );
  fprintf ( 1, 'correlation_heat_map():' );
  fprintf ( 1, '  Normal end of execution.' );
  timestamp ( );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

