Appends data to a variable in a GAUSS Data Archive.
gdaAppend(filename, x, varname)¶
filename (string) – name of data file.
x (matrix or array, string or string array) – data to append.
varname (string) – variable name.
retcode (scalar) –
return code, 0 if successful, otherwise one of the following error codes:
Null file name.
File open error.
File write error.
File read error.
Invalid data file type.
Variable not found.
File contains no variables.
File too large to be read on current platform.
Argument wrong size.
Data must be real.
Data must be complex.
// Generate random x matrix x = rndn(100, 50); /* ** Create a GDA named `myfile` ** and overwrite existing `myfile` */ retcode1 = gdaCreate("myfile.gda", 1); /* ** Write x matrix to `myfile` GDA ** and name it x1 */ retcode2 = gdaWrite("myfile.gda", x, "x1"); // Generate random y matrix y = rndn(25, 50); /* ** Append y to existing x1 variable ** in `myfile.gda` */ retcode3 = gdaAppend("myfile.gda", y, "x1"); // Check orders of x1 gdaGetOrders("myfile.gda", "x1");
This prints :
y matrix to
x1 adds \(25*50 = 1250\) elements to
x1, making it a 125x50 matrix.
This command appends the data contained in x to the variable varname in filename. Both x and the variable referenced by varname must be the same data type, and they must both contain the same number of columns.
gdaAppend() increases the size of the variable, it moves the
variable to just after the last variable in the data file to make room
for the added data, leaving empty bytes in the variable’s old location.
It also moves the variable descriptor table, so it is not overwritten by
the variable data. This does not change the index of the variable
because variable indices are determined NOT by the order of the variable
data in a GDA, but by the order of the variable descriptors. Call
gdaPack() to pack the data in a GDA, so it contains no empty bytes.