save
Save variables in the MAT file, filename.
Syntax
save(filename)
save(filename, format)
save(filename, variables)
save(filename, variables, format)
save(filename, ..., options)
Inputs
- filename
- Name of the MAT file to save. By default, the file saved will be in -v5 binary format and overwritten, unless specified by format or options.
- format
- Optional argument specifing the format of filename.
- options
- -append
- filename will not be overwritten and the variables to be saved will be appended to the existing file, it is exists.
- -ascii
- filename will be savedd as a text file and real, numerical data will be written.
- variable
- Optional list of the variables to save, separated by a comma.
Examples
Save data to a .mat file using save function:
st='hello';
M = [1923.71288 4023.03575 9768.82832 9195.83701 104.13143 4261.35201];
save('file.mat') % Saves all varaibles
save('file.mat','M') % Save specific variable
save('file.mat','M','-v7.3') % Save specific variable with v7.3 format
Save a 2D matrix with single precision data in a .mat file:
M = [1923.71288 4023.03575 9768.82832 9195.83701 104.13143 4261.35201];
single(M);
save('file.mat','M');
Append variables to an existing file:
M = [1923.71288 4023.03575 9768.82832 9195.83701 104.13143 4261.35201];
save('file.mat'); % Overwrite, if file exists
a = 10;
save('file.mat', '-append'); % Append to previously existing file