FILE_INCREMENT
Increment an Integer Array Stored in a File


FILE_INCREMENT is a MATLAB program which increments every entry of an integer array which is stored in a file.

The program is restricted to handling a file that can be recognized as having M lines of text, each line containing N integer values.

The program might be most naturally useful if a given file contains an array of index values that need to be converted between 0-based and 1-based indexing.

Note that the following MATLAB commands will work faster:

        array = load ( 'input_file' );
        array = array + increment;
        save -ASCII 'output_file' array;
      
However, the data is written in real number format, with exponents. I specifically want the output to be integers in recognizably integer formats. I don't care if it takes longer and requires more MATLAB commands.

Usage:

file_increment ( 'input_file', 'output_file', increment )
where

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Data and Programs:

FILUM is a MATLAB library which can work with information in text files.

TABLE_SCALE, a FORTRAN90 program which reads a TABLE file of N points in M dimensions and creates a copy with every entry scaled by a given scale vector.

TABLE_SHIFT, a FORTRAN90 program which reads a TABLE file of N points in M dimensions, creates a copy with every entry shifted by a given displacement vector.

Source Code:

Examples and Tests:

RBC is a set of 500 3D nodes and 996 triangles. The triangle data was given using 1-based indexing, but the plotting program to be used expected 0-based indexing. Therefore, the file RBC_ELEMENTS_0.TXT was created by the command:

        file_increment ( 'rbc_elements_1.txt', 'rbc_elements_0.txt', -1 )
      

You can go up one level to the MATLAB source codes.


Last revised on 06 February 2010