python/Matlab interoperability

1 回表示 (過去 30 日間)
Marco Halder
Marco Halder 2019 年 3 月 28 日
回答済み: Dhruv 2025 年 1 月 2 日
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

回答 (1 件)

Dhruv
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!

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by