python/Matlab interoperability
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
The current matlab implementation uses the python `array.array` class, when calling python code from matlab. This is quite inconvenient, since almost nobody in the python world uses `array.array`. The defacto standard is numpy. Are there any plans to enhance interoperability? In particular, the handling of complex data is currently not ideal.
Best regards
0 件のコメント
回答 (1 件)
Dhruv
2025 年 1 月 2 日
I understand that you would like to use Python's 'NumPy' since handling complex data is not ideal upon using 'array.array', which is just a memory view representation. MATLAB uses 'array.array' because it does not assume that the target machine uses 'NumPy'. Additionally, if the user does not want to use 'NumPy', then it is convenient to use 'array.array'.
However, it is quite easy to convert an 'array.array' into 'NumPy' array in MATLAB. The following example declares an 'array.array', and then converts it into 'NumPy' array.
xA = py.array.array('d',[1,2,3])
xNA = py.numpy.array(xA)
I hope this helps!
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!