Skip to content

save

Save workspace variables to a file.

save
save(filename)
save(filename, var1, var2, ...)
save(filename, '-options')

Saves variables from the current workspace to disk. Without arguments, saves all variables to matlab.mat. With a filename, saves to that file. With variable names, saves only those.

The '-options' form supports flags: '-mat' (binary MAT format, default), '-ascii' (text), '-append' (add to existing file without overwriting), '-v7.3' (HDF5-based for files >2GB).

save
save('data.mat', 'x', 'y')
save('data.txt', 'A', '-ascii')
  • load — Load variables from a file into the workspace.
  • csvwrite — Write a matrix to a CSV file.
  • xlswrite — Write data to an Excel (.xlsx) file.