In order to read a .mat Matlab file from your Python code, you can make use of the scipy.io module.
This module contains scipy.io.loadmat() method which you can use to load a .mat file.
Example with spicy.io module:
import scipy.io
my_matlab_file = scipy.io.loadmat('my_matlab_file.mat')
patient = my_matlab_file['patient']
infection = my_matlab_file['infection']
treatment = my_matlab_file['treatment']
print(patient)
print(infection)
print(treatment)
Example with h5py module:
import h5py
my_matlab_file = h5py.File('my_matlab_file.mat', 'r')
data_x = my_matlab_file['data_x']
data_y = my_matlab_file['data_y']
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!