How to efficiently convert Matlab engine arrays to numpy ndarray?

后端 未结 2 1992
[愿得一人]
[愿得一人] 2020-12-05 16:00

I am currently working on a project where I need do some steps of processing with legacy Matlab code (using the Matlab engine) and the rest in Python (numpy).

I noti

2条回答
  •  死守一世寂寞
    2020-12-05 16:18

    Tim's answer is great for 2D arrays, but a way to adapt it to N dimensional arrays is to use the order parameter of np.reshape() :

    np_x = np.array(x._data).reshape(x.size, order='F')

提交回复
热议问题