Dear all,
I want to implement an opensource nonlinear solver in Simulink such that it is suitable for code-generation (XPC-target). For this I want to convert an existing .mex file into an S-function.
Some background info:
I am using the IPOPT nonlinear solver which is supplied with the OptiToolbox (opensource) compliled as a precompiled .mex file which works perfectly under Matlab. However, to be able to use the solver in XPC-target I need to create and S-function block in Simulink.
Other options I've tried so far:
Question
After some search on fora and Matlab central, I found out that I should create a C MEX S-function and compile it. To make life easier, Simulink comes with an S-function builder in which libraries, headers etc. can be added. I failed in constructing one and it is driving me crazy.
I think it would be easiest to convert the .mex function into an S-function (if possible). My question to you therefor is:
Who has experience in converting an .mex function (based on a large set of C++ routines) into an S-function in Simulink
Your help will be greatly appreciated!
It is not at all possible to convert a .mex file into S-function.
Let me clarify something...
Now for your issue, you can try this...
If you have C/C++ routines as source (I mean source code of your mex file), no need to convert them all to S-function routine. Simply create a simulink S-function and call your existing C/C++ function in this s-function. You can do this by using S-function builder or legacy code tool. These both tools generates S-function and their inlining TLC files. Once generated, files can be modified as per need.
See...
Example Using S-Functions to Incorporate Legacy C Code
Integrating Existing C Functions into Simulink Models with the Legacy Code Tool
0 Comments