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?

回答 (1 件)

Hitesh
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:

カテゴリ

Help Center および File ExchangePython Package Integration についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by