1

I'm trying to load a MAT file that is a cell array of structs. Each of those structs have many fields, some of which are themselves cells.

A typical call would be:

 myCell{1}.myStructField{1}.myStructField

How do I load such a nested structure into Python?

Thanks for your thoughts.

1 Answer 1

2

scipy.io.loadmat will load the mat file if it's pre-v7.3; you can then access it like matfile['myCell'][0]['myStructField'][0]['myStructField'].

If it's v7.3 or higher, you can use h5py; after opening it, I think it'll also be f['myCell'][0]['myStructField'][0]['myStructField'], though you'll need to worry about possibly transposing the matrices because of column-major / row-major differences.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.