Compiling and using a mexFunction in Simulink

2 views (last 30 days)
Hello,
I'm not too familiar with S-functions, mex functions, and the use of C overall in MATLAB. There is a utility I want to use found here: https://github.com/mtli/FastFloodFill It has a cpp source file that uses the MATLAB mex interface. The generated mex files work great in the demo_fastfloodfill.m file.
I would like to incorporate this function into a simulink project. Is there a way to just include the source somehow? I've looked into using the C function blooks and I've tried the s-functionbuilder but had no success. It seems to me that if I were able to copy some stuff into the S-Function builder properly, I could get things to work, but I can't figure out how. My knowledge of c++ is quite limited, and I am having trouble working with the data types to try and make this a custom function.

Answers (1)

Eshan Patel
Eshan Patel on 2 Nov 2022
Hey Samuel,
I understand that you would like to use the MEX file/function in the GitHub repo with your Simulink model. To do this, you can use the MATLAB Function Block and invoke the MEX function from there. You would not need to use S-functions this way, but this approach will not be supported for code generation. You can refer to this answer for some more details:

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!