function table = itable_data_read ( input_filename ) %% ITABLE_DATA_READ reads data from an integer table file. % % Modified: % % 22 October 2004 % % Author: % % John Burkardt % % Parameters: % % Input, character INPUT_FILENAME(*), the name of the input file. % % Output, integer TABLE(M,N), the point coordinates. % m = file_column_count ( input_filename ); n = file_row_count ( input_filename ); % % Build up the format string for reading M real numbers. % string = ' '; for i = 0 : m string = strcat ( string, ' %d' ); end input_unit = fopen ( input_filename ); if ( input_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'ITABLE_DATA_READ - Error!\n' ); fprintf ( 1, ' Could not open the input file.\n' ); error ( 'ITABLE_DATA_READ - Error!' ); return; end i = 0; while ( i < n ) line = fgets ( input_unit ); if ( line == -1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'ITABLE_DATA_READ - Error!\n' ); fprintf ( 1, ' End of input while reading data.\n' ); error ( 'ITABLE_DATA_READ - Error!' ); end if ( line(1) == '#' ) elseif ( s_len_trim ( line ) == 0 ) else [ x, count ] = sscanf ( line, string ); if ( count == m ) i = i + 1; table(1:m,i) = x(1:m); end end end fclose ( input_unit );