save
Save variables in a the .MAT format file
Syntax
save(filename)
save(filename, format)
save(filename, variables)
save(filename, variables, format)
save(filename, '-struct', structvariables, format)
save(filename, ..., options)
Inputs
- filename
 - Name of the file to save in .MAT format. By default, the file saved will be saved in -v5 binary format and overwritten, unless specified by format or options.
 - format
 - Optional argument specifying the MAT 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 saved as a text file and real, numerical data will be written.
 
 - variable
 - Optional list of the variables to save, separated by a comma.
 - structvariables
 - Optional comma separated list of the struct variables.
 
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 formatSave 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 fileSaving struct fields as
        variables:
    mystruct = struct('data1',[],'data2',[], 'data3',[],'data4',[]);
mystruct.data1 = {'foo®'};
mystruct.data2 = 5;
mystruct.data3 = 4;
mystruct.data4 = 9;
curves = struct('name',[]);
curves.name = '123®';
save('struct1.mat', '-struct', 'mystruct', 'curves')
clear all
load('Session.mat')
whos
 Attr Name          Size Bytes Class 
 ==== ====          ==== ===== ===== 
      CurveFitting  1x1      8 double
      Extrapolation 1x1      8 double
      FinalCurves   1x1      8 double
      ImportData    1x1     18 cell  
      name          1x18    18 char