%% file_script writes a table of integers to a file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 December 2019
%
%  Author:
%
%    John Burkardt
%
fprintf ( 1, '\n' );
fprintf ( 1, 'file_script\n' );
fprintf ( 1, '  A MATLAB script to write a short table to a file.\n' );

file_name = 'file.txt';
file_unit = fopen ( file_name, 'w' );
fprintf ( file_unit, '\n' );
fprintf ( file_unit, '           N   N-squared     N-cubed\n' );
fprintf ( file_unit, '\n' );
for i = 0 : 10
  fprintf ( file_unit, '  %10d  %10d  %10d\n', i, i^2, i^3 );
end
fclose ( file_unit );

fprintf ( 1, '\n' );
fprintf ( 1, '  file_script wrote the file "%s"\n', file_name );
%
%  Terminate.
%
fprintf ( 1, '\n' );
fprintf ( 1, 'file_script\n' );
fprintf ( 1, '  Normal end of execution.\n' );
%
exit ( )
