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 CenterFile Exchange에서 Call 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