Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Numpy: Save a Numpy array as a Matlab file

import scipy.io
import numpy as np

data = np.random.random((2, 5))
print(data)

file_path = 'data.mat'
scipy.io.savemat(file_path, {'data': data})