cannot import matlab file to python code
Question: I am on a project on machine learning. trained the data in matlab R2015a and
obtained a file abc.m . I get the expected result from matlab file while
giving input from the matlab command window. i have developed the interface in
pyqt5 and got the file in python . Want to import .m file to python for usage.

have Anaconda 2.4.1 installed on my computer with python 3.5. working on
Windows 8.1

Can anyone help ? totally stuck with the project.

My code is as follows :

    
    
    import scipy.io as sio
    import numpy as np
    
    from sklearn import preprocessing
    
    ab = sio.loadmat('latest.m')
    ......
    

But i get the following error :

    
    
    Traceback (most recent call last):
    File "test.py",line 8,in <module>
     ab = sio.loadmat('latest.m')
     File "C:\anaconda\Lib\site-packages\scipy\io\matlab\mio.py",line 58,in mat_reader_factory
     mjv,mnv = get_matfile_version(byte_stream)
     File "C:\anaconda\Lib\site-packages\scipy\io\matlab\miobase.py",line 241,in get_matfile_version
     raise ValueError('Unknown mat file type,version %s,%s' % ret)
     ValueError: Unknown mat file type,version 111,114
    


Answer: [`loadmat`](https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.io.loadmat.html)
loads a MATLAB data file, e.g. the result of some code. MATLAB data files have
`.mat` extension.

Loading a `.m` file means loading a bunch of text that doesnt mean anything
without a MATLAB interpreter! What you want is to load a `.mat` file, a file
containing matrices, strings or whatever it has been saved there.

**EDIT** I have just seen @valtuarte 's link to [What is the difference
between .m and .mat files in
MATLAB](https://stackoverflow.com/questions/3947549/what-is-the-difference-
between-m-and-mat-files-in-matlab) . Have a check!

