read mat file python code example
Example 1: python open mat file
import scipy.io
mat = scipy.io.loadmat('file.mat')
Example 2: open mat file in python
#!python
#!/usr/bin/env python
from scipy.io import loadmat
x = loadmat('test.mat')
lon = x['lon']
lat = x['lat']
# one-liner to read a single variable
lon = loadmat('test.mat')['lon']
Example 3: open mat python
from mat4py import loadmat
data = loadmat('datafile.mat')
Example 4: read .mat file in python
with h5py.File('test.mat', 'r') as file:
a = list(file['a'])