MATLABファイルのインポート

Python でのデータインポート入門

Hugo Bowne-Anderson

Data Scientist at DataCamp

MATLAB

  • "Matrix Laboratory"
  • 工学・科学で広く使われている
  • データは.matファイルとして保存される

ch_2_4.005.png

Python でのデータインポート入門

SciPyが役立つ!

  • scipy.io.loadmat() - .matファイルの読み込み
  • scipy.io.savemat() - .matファイルの書き込み
Python でのデータインポート入門

.matファイルとは?

ch_2_4.010.png

Python でのデータインポート入門

.matファイルとは?

ch_2_4.011.png

Python でのデータインポート入門

.matファイルのインポート

import scipy.io
filename = 'workspace.mat'
mat = scipy.io.loadmat(filename)

print(type(mat))
<class 'dict'>
  • キー = MATLAB変数名
  • 値 = 変数に代入されたオブジェクト
print(type(mat['x']))
<class 'numpy.ndarray'>
Python でのデータインポート入門

練習しましょう!

Python でのデータインポート入門

Preparing Video For Download...