Import package in script embedded in Simulink model

조회 수: 4 (최근 30일)
Erik Börve
Erik Börve 2022년 4월 19일
답변: zhouhang 2023년 11월 27일
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일
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.

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by