How to load and convert .mat file into numpy 2D array?

12,616

Use scipy's loadmat (API-docs).

The docs should be sufficient to get you going, but make sure to read the notes.

There is also the io-tutorial with some examples.

Share:
12,616
Abdullah Danyal
Author by

Abdullah Danyal

Currently working with high throughput distributed systems on a scale ensuring high quality delivery, service scalability and reliability through effective code and data storage design. Tags: JavaScript, NodeJS, Microservices, SQL and NOSQL databases, React, Redux, Docker, Kubernetes, Helm, Terraform, Redis, API Gateway, pub/sub. while(!(succeed = try())); Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program- Linus Torvalds (Principal Developer of Linux)

Updated on June 05, 2022

Comments

  • Abdullah Danyal
    Abdullah Danyal almost 2 years

    I have a data in mat file (observations and features) and i want to load it into numpy 2D array. I dont want to convert it into csv first and then load csv into numpy.

  • user7194905
    user7194905 almost 6 years
    So useful. The loadmat() returns a dict type and we can get the array by its key.