I have a .mat file, with only the following data inside : cell{Name,Matrix(1610x10)} and I would like to obtain the matrix data in a numpy array to process it. Thanks
Asked
Active
Viewed 60 times
1 Answers
0
You could save the data as CSV and read the data with python. After this transform it to a numpy array.
http://www.mikesoltys.com/2014/04/06/readingwriting-to-csv-in-matlab/
in python:
csvData = []
with open("DATA.csv") as data:
csv_reader_objekt = csv.reader(data)
for row in csv_reader_objekt:
csvData.append(row)
DataArray = np.array(csvData)

Poopaye
- 44
- 9
-
Thanks. But the problem is that I have a vast amount of files to convert to CSV. My problem was, once I have loaded the document, and accessed to the cell, how can I obtain the data matrix? – morser Jan 19 '21 at 16:10
-
I have tried this: from scipy.io import loadmat arr = np.arange(1601*10).reshape(1601,10) annots = loadmat('examp.mat') But then, I still don´t know how to obtain the matrix – morser Jan 19 '21 at 16:13
-
If you use `np.reshape` you should have a data matrix already. Ah `loadmat` i remember using this in my first semester. You can try to print out the shape of the matrix to check it `print(arr.shape)` – Poopaye Jan 19 '21 at 16:26