Importation de fichiers MATLAB

Introduction à l'importation de données en Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

MATLAB

  • « Laboratoire Matrix »
  • Norme industrielle en ingénierie et en sciences
  • Données enregistrées sous forme de fichiers .mat

ch_2_4.005.png

Introduction à l'importation de données en Python

SciPy à la rescousse !

  • scipy.io.loadmat() - lit les fichiers .mat
  • scipy.io.savemat() - écrit des fichiers .mat
Introduction à l'importation de données en Python

Qu'est-ce qu'un fichier .mat ?

ch_2_4.010.png

Introduction à l'importation de données en Python

Qu'est-ce qu'un fichier .mat ?

ch_2_4.011.png

Introduction à l'importation de données en Python

Importation d'un fichier .mat

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

print(type(mat))
<class 'dict'>
  • keys = noms de variables MATLAB
  • valeurs = objets attribués à des variables
print(type(mat['x']))
<class 'numpy.ndarray'>
Introduction à l'importation de données en Python

Passons à la pratique !

Introduction à l'importation de données en Python

Preparing Video For Download...