regarding the "Calling from MATLAB from Python" interface: how would I convert back array data returned from a matlab function as matlab.double()
1 回表示 (過去 30 日間)
古いコメントを表示
I would like to refer to the example in the documentation, https://de.mathworks.com/help/matlab/matlab_external/use-matlab-arrays-in-python.html.
In the example the engine returns b, which is a 1-by-5 matlab.double array.
To further process / use that result in python it might be necessary to convert it back to a python list.
Is there a better way to do this than the following, which might be inefficient and complicated for large multidimensional arrays?
b_py = [v for v in b[0]]
0 件のコメント
採用された回答
Elad
2020 年 5 月 14 日
Try
b._data
it should be much faster.
3 件のコメント
Elad
2020 年 5 月 14 日
編集済み: Elad
2020 年 5 月 14 日
That's always a good practice. However, until someone in Mathworks solve this issue, i'm not familar with more efficent way that doesn't include passing through Lists.
To transfer info the other way(and not waiting couple of minutes for a simple 3d array), I had to write even nastier piece of code :o
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!