datasave

Purpose

Saves matrices, N-dimensional arrays, strings and string arrays to a disk file.

Format

ret = datasave(filename, x)
Parameters:
  • filename (string) – name of data file.
  • x (matrix, array, string or string array) – data to write to disk.
Returns:

ret (scalar) – return code, 0 if successful, or -1 if it is unable to write the file.

Examples

// Create random matrix
x = rndn(1000, 100);

/*
** Save x to file named
** myfile.fmt
*/
ret = datasave("myfile.fmt", x);

Remarks

datasave() can be used to save matrices, N-dimensional arrays, strings and string arrays. The following extensions are given to files that are saved with datasave():

matrix .fmt
array .fmt
string .fst
string array .fst

Use dataload(), or loadd() to load a data file created with datasave().

See also

Functions save, dataload()