[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` loadmat  `

#  scipy.io.loadmat  #

scipy.io.  loadmat  (  _ file_name  _ , _ mdict  =  None  _ , _ appendmat  =
True  _ , _ **  kwargs  _ )  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/matlab/_mio.py#L86-L234)
#

    

Load MATLAB file.

Parameters  :

    

**file_name** str

    

Name of the mat file (do not need .mat extension if appendmat==True). Can also
pass open file-like object.

**mdict** dict, optional

    

Dictionary in which to insert matfile variables.

**appendmat** bool, optional

    

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

**byte_order** str or None, optional

    

None by default, implying byte order guessed from mat file. Otherwise can be
one of (ânativeâ, â=â, âlittleâ, â<â, âBIGâ, â>â).

**mat_dtype** bool, optional

    

If True, return arrays in same dtype as would be loaded into MATLAB (instead
of the dtype with which they are saved).

**squeeze_me** bool, optional

    

Whether to squeeze unit matrix dimensions or not.

**chars_as_strings** bool, optional

    

Whether to convert char arrays to string arrays.

**matlab_compatible** bool, optional

    

Returns matrices as would be loaded by MATLAB (implies squeeze_me=False,
chars_as_strings=False, mat_dtype=True, struct_as_record=True).

**struct_as_record** bool, optional

    

Whether to load MATLAB structs as NumPy record arrays, or as old-style NumPy
arrays with dtype=object. Setting this flag to False replicates the behavior
of scipy version 0.7.x (returning NumPy object arrays). The default setting is
True, because it allows easier round-trip load and save of MATLAB files.

**verify_compressed_data_integrity** bool, optional

    

Whether the length of compressed sequences in the MATLAB file should be
checked, to ensure that they are not longer than we expect. It is advisable to
enable this (the default) because overlong compressed sequences in MATLAB
files generally indicate that the files have experienced some sort of
corruption.

**variable_names** None or sequence

    

If None (the default) - read all variables in file. Otherwise,
_variable_names_ should be a sequence of strings, giving names of the MATLAB
variables to read from the file. The reader will skip any variable with a name
not in this sequence, possibly saving some read processing.

**simplify_cells** False, optional

    

If True, return a simplified dict structure (which is useful if the mat file
contains cell arrays). Note that this only affects the structure of the result
and not its contents (which is identical for both output structures). If True,
this automatically sets _struct_as_record_ to False and _squeeze_me_ to True,
which is required to simplify cells.

Return