function printout( t, fmt, hdr )

% printout(t, fmt, hdr)    prints the table t under format control in 'fmt'
%	
%       fmt is an ascii string specifying the format ( default is ' %10.42f' ).
%	hdr is an optional ascii header, printed at the top of the table

echo printout off

def_fmt = ' %10.2f' ;		% default format specification

	
		% take care of argument list options

if nargin == 1			% if only 1 argument, then no hdr
	fmt = def_fmt ;		% use default format
	hdr = ' ' ;
end ;

if nargin == 2			% do case of 2 arguments
	if fmt(1) == '%'	% if legal format specification, then no hdr
		hdr = ' ' ;
	else
		hdr = fmt ;	% else 2nd argument is the hdr
		fmt = def_fmt ;
	end
end ;

		% test for legal hdr and print

[row, col] = size( hdr ) ;

if row > 1

	error(' error: header must be a row vector') ;

else				% hdr legal -print it!
     fprintf('\n\n        ');   
	fprintf([hdr '\n\n']) ;

end ;

		% finally, print the table t

[rows cols] = size( t ) ;

t=denanize(t,9999);
fprintf('\n\n\n\n');
for r = 1:rows
fprintf('                ');
	for c = 1:cols

		fprintf(fmt, t(r,c)) ;

	end ;
				% put each row on a new line
	fprintf( '\n') ;

end ;

fprintf( '\n\n\n') ;

goon=input('type 1 for printer output ');
if goon==1

[row, col] = size( hdr ) ;

if row > 1

	error(' error: header must be a row vector') ;

else				% hdr legal -print it!

     fprintf('PRN','\n\n        ');
	fprintf('PRN',[hdr '\n\n']) ;

end ;

		% finally, print the table t

[rows cols] = size( t ) ;

t=denanize(t,9999);
fprintf('PRN','\n\n\n\n');
for r = 1:rows
fprintf('PRN','                ');
	for c = 1:cols

		fprintf('PRN',fmt, t(r,c)) ;

	end ;
				% put each row on a new line
	fprintf('PRN', '\n') ;

end ;

fprintf('PRN', '\n\n\n') ;

goon=input('type 1 for formfeed ');
if goon==1
       !formfeed
end

end
