Use of Simulink-generated MEX function within MATLAB

5 views (last 30 days)
Assume that you have a MATLAB function that generates a waveform (vector A) and a Simulink model that represents a combination of filters.
Is there any way, by which, the Simulink model can be invoked through MATLAB as a MEX function (eg B = sim_func_mex(A)) in order to pass the waveform through the filters and obtain the output (vector B) WITHOUT opening Simulink (ie without issuing a sim() command) and without requiring a Simulink license?
This scenario is very common, where a number of people need to work on a MATLAB function but DO NOT need access (i.e. they do not need to view/modify) the Simulink model.
Any help would be very much appreciated.
Regards, Ioannis

Answers (2)

Titus Edelhofer
Titus Edelhofer on 16 Apr 2015
Hi Ioannis,
if you have Simulink Coder available, you can convert your Simulink model to C Code (and create either an executable or a dll). This you (other users) can call then from MATLAB without the need of Simulink. What you need though is the license for Simulink Coder ...
Titus

Ioannis Sarris
Ioannis Sarris on 16 Apr 2015
Thanks Titus for your answer. I have thought of this possibility but I would expect that a simpler solution should be possible, since this requires building a MEX wrapper for the C-code and compiling it. At the end of the day, Simulink creates a MEX file of your model in Accelerated mode, so why is it not possible to reuse that?
Thanks again.
  1 Comment
Simon Meyer
Simon Meyer on 28 Sep 2020
Hello Ioannis,
currently I am struggeling with the same problem. I know this post is pretty old, but did you find any good way to solve this issue, or can you give any advice for me?
Thank you very much!
Simon

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!