0

I have some data stored in a 1x1 with 8 fields struct in matlab. I want to store the data of each field (which is a table) in a matrix in Python

I tried this:

import scipy.io
import numpy as np

# Load the .mat file
data = scipy.io.loadmat('file.mat')

# Access the struct within the loaded data
my_struct = data['structkey']

# Convert each table to a matrix
table1_matrix = my_struct['table1'][0, 0]['arr']
print(table1_matrix)

but this is what I got:

[array([[3707764736],
[         2],
[         1],
[         1],
[         1],
[         1]], dtype=uint32)]

each table is 15200*51 and I need the data stored in it but I have no idea how to access it

Mayssa
  • 1
  • 2
  • So the file contains a MATLAB struct and each field of the struct is a MATLAB table? There are many answers here already about reading from .mat files into Python but the MATLAB tables may be an issue - if possible you might find it easier to re-save the data in a different form. See for e.g. these questions: [1](https://stackoverflow.com/questions/874461/read-mat-files-in-python), [2](https://stackoverflow.com/questions/67996837/read-table-variable-in-a-matlab-v7-3-file-with-python), [3](https://stackoverflow.com/questions/25853840/load-matlab-tables-in-python-using-scipy-io-loadmat). – nekomatic Jul 07 '23 at 09:05

0 Answers0