FUNCTION REFERENCE
save
Save workspace variables to a MAT file or ASCII text.
Save workspace variables to a MAT file or ASCII text.
Syntax
save('data.mat')Syntax
save('data.mat', 'A', 'B', '-v7.3')Syntax
save data.mat ASyntax
save data.txt A -ascii -double -tabsWithout names it saves all variables. -ascii writes 2-D double arrays as text (complex arrays use their real parts); other types are skipped with a warning. An explicit ASCII filename is used as given. ASCII uses 8 significant digits by default and 17 with -double, spells special values Inf, -Inf and NaN, and separates columns with tabs when given -tabs. The default file is matlab.mat. Versions: -v6, -v7 (default), -v7.3; -nocompression needs -v7.
Example
A=5; save('data.mat','A') % A is savedPlain structs preserve field order, shape and supported field types. The -struct option takes a scalar struct variable name and optionally field names; each selected field is saved as a separate variable. Sparse fields are supported in -v6 and -v7; v7.3 sparse persistence remains unsupported. Nonempty nonscalar structs without fields are also rejected in -v7.3 because the group has no field-reference shape.
Differences from MATLAB: Statement only; no output assignment. No -append or wildcards. Objects and function handles cannot be saved.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.