save

Save variables into a MAT file.

Syntax

save(filename, variables)

save(filename, variables, format)

save(filename)

save(filename, format)

save filename

Inputs

filename
Path and name of the MAT file to read.
Type: string
variable
List of the variables to save, separated by a comma.
If no variable is specified, all variables are saved.
Type: string
format
Specifies the format of the file to save. If omitted, format 7.3 is assumed.
Type: string
Valid entries for format:
  • '-v5' - indicates to save using v5 format.
  • '-v7.3' - indicates to save using v7.3 format.

Example

Save data to a .mat file using save function:

% create some string
st='hello';
% create a matrix
M = [ 1923.71288  4023.03575  9768.82832  9195.83701  104.13143  4261.35201   ];
% save to file
save('file.mat')
% save only the matrix to file
save('file.mat','M')
% save only the matrix to file, with v5 format
save('file.mat','M','-v5')