
MATLAB python package not accepting mlarray.double type as input in Matlab2022 (Runtime R2022a 9.12)
조회 수: 5 (최근 30일)
이전 댓글 표시
I have been creating Python packages (using the library compiler tool) from custom functions that take as input multidimensional arrays using matlab runtime R2021a (9.10) and using them in python as follows:
From python:
import matlab
import calculations
my_calculations = calculations.initialize()
maximum_2D_array = matlab.double(maximum_matrix, size=np.array(maximum_matrix).shape)
matrix_3D_array = matlab.double(matrix_array, size=np.array(matrix_array).shape)
my_calculations.CustomFunction(maximum_2D_array,matrix_3D_array, nargout=0)
I did it this way because Matlab only accepts arrays of same size, that is why I used np.array.shape as size. So far this was working great, but now our matlab was updated to the 2022 version. I updated the Matlab runtime to (Runtime R2022a 9.12) and created the python package again but now this same code is not working and is always throwing me this error:
TypeError: unsupported Python data type: mlarray.double
Traceback (most recent call last):
File "c:/Users/user/Documents/matlabtests/Matlab_calculations.py", line 6
my_calculations.CustomFunction(maximum_2D_array,matrix_3D_array, nargout=0) File "C:\MATLAB\Runtime\v912\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\deployablefunc.py", line 70, in __call__
future_tuple = self._cppext_handle.evaluateFunction(self._mcr_handle, self._name, nlhs, args,
SystemError: <built-in function evaluateFunction> returned NULL without setting an error
Does anyone have an idea why this happened? did something changed on the new matlab runtime that somehow now it does not accept matlab doubles as input?
댓글 수: 0
답변 (1개)
Hitesh
2025년 2월 4일
Hi Martin,
I too encountered the similar issue, the workaround that worked for me was to import "matlab.engine" and converting the arrays to list. I have revised your code and attached the image of the output.

For more information regarding the "MATLAB Engine", refer to the following MATLAB documentation:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Python Package Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!