Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transfer variables from Matlab to Python

I would like to transfer some of variables calculated in Matlab (R2022a) to Python environment (3.10).

I have figured out that the SciPy package has function loadmat() and I may save vars in mat file and then I should read the file with Python. However, I'm not able to use the function.

import scipy
scipy.loadmat('myVars.mat')

The interpreter argues that there is no such function as loadmat().

Thanks in advance!


1 Answers

You are importing the wrong package, check the docs.

import scipy.io as sio

mat_file = sio.loadmat('myVars.mat')
like image 199
alexrogo Avatar answered May 16 '26 01:05

alexrogo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!