Updates a variable in a GAUSS Data Archive.
gdaUpdate(filename, x, varname)¶
- filename (string) – name of data file.
- x (matrix) – array, string or string array, data.
- varname (string) – variable name.
retcode (scalar) –
return code, 0 if successful, otherwise one of the following error codes:
1 Null file name. 2 File open error. 3 File write error. 4 File read error. 5 Invalid data file type. 8 Variable not found. 10 File contains no variables. 14 File too large to be read on current platform.
// Generate random variable x x = rndn(100, 50); // Create GDA `myFile` retcode1 = gdaCreate("myfile.gda", 1); // Write `x` to `myfile` as x1 retcode2 = gdaWrite("myfile.gda", x, "x1"); // Generate random variable y y = rndn(75, 5); // Update x1 with y retcode3 = gdaUpdate("myfile.gda", y, "x1");
This command updates the variable varname in filename with the data contained in x.
If x is larger than the specified variable in the file, then
writes the new variable data after the last variable in the data file,
moving the variable descriptor table to make room for the data and
leaving empty bytes in the place of the old variable. 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
If x is the same size or smaller than the specified variable in the
gdaUpdate() writes the data in x over the specified variable.
If x is smaller, then
gdaUpdate() leaves empty bytes between the end of
the updated variable and the beginning of the next variable in the data
This command updates variables quickly by not moving data in the file
unnecessarily. However, calling
gdaUpdate() several times for one file may
result in a file with a large number of empty bytes. To pack the data in
a GDA, so it contains no empty bytes, call
gdaPack(). Or to update a
variable without leaving empty bytes in the file, call