bundles / scipy 1.17.1 / scipy / io / matlab / _mio / savemat
function
scipy.io.matlab._mio:savemat
source: /scipy/io/matlab/_mio.py :252
Signature
def savemat ( file_name , mdict , appendmat = True , format = 5 , long_field_names = False , do_compression = False , oned_as = row ) Summary
Save a dictionary of names and arrays into a MATLAB-style .mat file.
Extended Summary
This saves the array objects in the given dictionary to a MATLAB- style .mat file.
Parameters
file_name: str or file-like objectName of the .mat file (.mat extension not needed if
appendmat == True). Can also pass open file_like object.mdict: dictDictionary from which to save matfile variables. Note that if this dict has a key starting with
_or a sub-dict has a key starting with_or a digit, these key's items will not be saved in the mat file and MatWriteWarning will be issued.appendmat: bool, optionalTrue (the default) 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, optionalFalse (the default) - maximum field name length in a structure is 31 characters which is the documented maximum length. True - maximum field name length in a structure is 63 characters which works for MATLAB 7.6+.
do_compression: bool, optionalWhether or not to compress matrices on write. Default is False.
oned_as: {'row', 'column'}, optionalIf 'column', write 1-D NumPy arrays as column vectors. If 'row', write 1-D NumPy arrays as row vectors.
Examples
from scipy.io import savemat import numpy as np a = np.arange(20) mdic = {"a": a, "label": "experiment"}✓
mdic
✗savemat("matlab_matrix.mat", mdic)
✓Aliases
-
scipy.io.savemat