scipy.io.savemat

scipy.io.savemat(file_name, mdict, appendmat=True, format='5', long_field_names=False, do_compression=False, oned_as=None)

Save a dictionary of names and arrays into a MATLAB-style .mat file.

This saves the array objects in the given dictionary to a MATLAB- style .mat file.

Parameters :

file_name : str or file-like object

Name of the .mat file (.mat extension not needed if appendmat == True). Can also pass open file_like object.

m_dict : dict

Dictionary from which to save matfile variables.

appendmat : bool, optional

True to append the .mat extension to the end of the given filename, if not already present.

format : {‘5’, ‘4’}, string, optional

‘5’ (the default) for MATLAB 5 and up (to 7.2), ‘4’ for MATLAB 4 .mat files

long_field_names : bool, optional

  • False - maximum field name length in a structure is 31 characters which is the documented maximum length. This is the default.
  • True - maximum field name length in a structure is 63 characters which works for Matlab 7.6

do_compression : bool, optional

Whether to compress matrices on write. Default is False.

oned_as : {‘column’, ‘row’}, optional

If ‘column’, write 1-D numpy arrays as column vectors. If ‘row’, write 1D numpy arrays as row vectors.

See also

mio4.MatFile4Writer, mio5.MatFile5Writer

Notes

If format == '4', mio4.MatFile4Writer is called, which sets oned_as to ‘row’ if it had been None. If format == '5', mio5.MatFile5Writer is called, which sets oned_as to ‘column’ if it had been None, but first it executes:

warnings.warn("Using oned_as default value ('column')" +
" This will change to 'row' in future versions", FutureWarning, stacklevel=2)

without being more specific as to precisely when the change will take place.

Previous topic

scipy.io.loadmat

Next topic

scipy.io.mminfo

This Page