Import package in script embedded in Simulink model

Hi everyone,
I'm solving an optimization problem using an external solver package. (CasADi to solve a model predictive control problem)
My system is modeled in Simulink and the package is imported in an embedded script as,
"import casadi.*"
When compiling the model I get the error message, "Import statements are currently unsupported" (I'm running R2017b)
Is there anyway around this issue for my version of matlab?

2 件のコメント

Saad Hamayoon
Saad Hamayoon 2022 年 8 月 10 日
Hi. Did you find a solution to this? If I used interpreted fcn block in simulink then my model works but it is very slow. Have you been able to implement this with MATLAB fcn block?
Regards,
Saad
Daniel Alejandro Poveda Pi
Daniel Alejandro Poveda Pi 2023 年 3 月 20 日
Hi! I'm having the same problem, has anyone arrived to a solution for this problem?
Thanks in advance,
Daniel

サインインしてコメントする。

回答 (1 件)

zhouhang
zhouhang 2023 年 11 月 27 日

0 投票

Hi, I have a solution.
I just put my code in a .m function file(e.g myfun.m) outside. And add
coder.extrinsic('import');
After that, call myfun in Simulink matlab-function, and add
coder.extrinsic('myfun');
Then, the error disappeared magically.

カテゴリ

ヘルプ センター および File ExchangeManual Performance Optimization についてさらに検索

製品

リリース

R2017b

質問済み:

2022 年 4 月 19 日

回答済み:

2023 年 11 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by