How to preserve matlab struct when accessing in python?

前端 未结 4 906
离开以前
离开以前 2021-02-08 04:41

I have a mat-file that I accessed using

from scipy import io
mat = io.loadmat(\'example.mat\')

From matlab, example.mat contains the following

4条回答
  •  时光取名叫无心
    2021-02-08 05:11

    (!) In case of nested structures saved in *.mat files, is necessary to check if the items in the dictionary that io.loadmat outputs are Matlab structures. For example if in Matlab

    >> thisStruct
    
    ans =
          var1: [1x1 struct]
          var2: 3.5
    
    >> thisStruct.var1
    
    ans =
          subvar1: [1x100 double]
          subvar2: [32x233 double]
    

    Then use the code by mergen in scipy.io.loadmat nested structures (i.e. dictionaries)

提交回复
热议问题