S-function builder external function

I am trying to solve a system of ODEs using S-function builder in Simulink to program the system of equations. The system of equations use an external MATLAB function that I programmed separately. The external function can be called from a MEX compiled code that uses base functions written in C++. I was wondering if the external function prompt in the S-function builder would allow for using the compiled MEX code and call the aforementioned MATLAB function so I can integrate it into my system of ODEs.
Thank you

3 件のコメント

Walter Roberson
Walter Roberson 2017 年 10 月 20 日
I have not used the S-function builder, but I know that MATLAB Function Blocks can call upon C/C++ code by using coder.extrinsic() and coder.ceval(), so I would tend to suspect there is some way.
Anurag Goyal
Anurag Goyal 2017 年 10 月 20 日
I have little to no experience in programming with C++ and S-function builder seemed an easier workaround for me to speedup my code for simulating a system of ODEs in simulink especially when simulating a system of 500+ equations. Is the mex compiled file still a C++ file or a MATLAB file? Thank you
Walter Roberson
Walter Roberson 2017 年 10 月 20 日
mex is used to compile C, C++ or Fortran.
Have you looked at the Symbolic Toolbox facilities for odes? In particular, you can build ODE symbolically, and then go through a couple of steps to convert them into MATLAB functions that can be called with ode45*() or the like.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

質問済み:

2017 年 10 月 20 日

コメント済み:

2017 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by