フィルターのクリア

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 Center および File ExchangeCall 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