필터 지우기
필터 지우기

python library in simulink matlab system block

조회 수: 6 (최근 30일)
David Håkansson
David Håkansson 2021년 8월 23일
편집: David Håkansson 2021년 8월 24일
Hi, I am trying to create a matlab system block in simulink that imports and uses a python library.
After setting up the python environment, I tried the following in the resetImpl method in the matlab system block:
obj.cst = py.importlib.import_module('a valid python library reference')
But that gives me an error:
Function 'py.importlib.import_module' is not supported for code generation. Consider adding coder.extrinsic('py.importlib.import_module') at the top of the function to bypass code generation.'
So I tried to add coder.extrinsic according to the proposal in the error message:
coder.extrinsic('py.importlib.import_module');
obj.cst = py.importlib.import_module('a valid python library reference')
which results in the error:
'Cannot pass a mxArray to 'SystemProp_matlabCodegenValidateAnyProp'.'
Any suggestions?
  댓글 수: 1
David Håkansson
David Håkansson 2021년 8월 24일
In many examples for coder.extrinsic, for example here the parameter needs to be pre-defined before running the extrinsic function. In that example it is on these lines:
y = 0;
y = mymin(N, D);
So that is easy when the data type that the mymin function returns is a double.
In my case I suspect I need to declare obj.cst as a python class before I call py.importlib.import_module. How to do that?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by