MATLAB-bestanden importeren

Introductie tot data importeren in Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

MATLAB

  • “Matrix Laboratory”
  • Industriestandaard in engineering en wetenschap
  • Data opgeslagen als .mat-bestanden

ch_2_4.005.png

Introductie tot data importeren in Python

SciPy schiet te hulp!

  • scipy.io.loadmat() - lees .mat-bestanden
  • scipy.io.savemat() - schrijf .mat-bestanden
Introductie tot data importeren in Python

.mat-bestand: wat is het?

ch_2_4.010.png

Introductie tot data importeren in Python

.mat-bestand: wat is het?

ch_2_4.011.png

Introductie tot data importeren in Python

Een .mat-bestand importeren

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

print(type(mat))
<class 'dict'>
  • keys = MATLAB-variabelnamen
  • values = objecten toegewezen aan variabelen
print(type(mat['x']))
<class 'numpy.ndarray'>
Introductie tot data importeren in Python

Laten we oefenen!

Introductie tot data importeren in Python

Preparing Video For Download...