matlab date string results in java lang string in python scipy.io

后端 未结 1 1457
情书的邮戳
情书的邮戳 2021-01-28 05:10
  • I have a field of type <1x1 java.lang.String> in Matlab. Its value is 13:06:40

  • When I read this mat-file in python,

相关标签:
1条回答
  • 2021-01-28 05:38

    Access .mat file containing matlab classes in python

    asks about a MATLAB class object with a similar loadmat display:

    MatlabOpaque([ (b'futureDS', b'MCOS', b'cStream', [[3707764736], ...])], 
      dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')])
    

    There's nothing in Python that can decode this kind of MATLAB or Java object. If you need to send data back and forth between MATLAB and scipy stick with the basic MATLAB arrays, cells, and struct.

    You could try to parse that arr list of numbers. Since they are all <256, they probably represent bytes. Can't you convert it to an ordinary MATLAB character string?

    In [117]: x=[172, 237, 0, 5, 116, 0, 8, 49, 50, 58, 48, 49, 58, 53, 49]
    In [118]: np.array(x,np.uint8).tostring()
    Out[118]: b'\xac\xed\x00\x05t\x00\x0812:01:51'
    

    The last 8 characters look like a time stamp. But do you know anything about java.lang.String objects?

    0 讨论(0)
提交回复
热议问题