How do I build my model containing a C-MEX S-function if I don't have the S-function C source file using Simulink Coder?

I was given a model which contains an S-function and the MEX file for the S-function. I need to build this model but I do not have the source file used in the S-function block. With this set up, how should I build my model?
 

 Accepted Answer

You can build the model even though you do not have the source file for the S-function. Please refer to the information below.
The person who gave you the model and MEX file, should follow the steps below: 
  1. Build any model that contains the desired S-function, say mysfunction.c using Simulink Coder.
  2. The generated RTW folder (modelname_target_rtw) will contain a file named mysfunction.obj.
They should send the following files to you: 
  • Simulink Model
  • S-function object (mysfunction.obj)
  • MEX-file generated (mysfunction.mexext, which is mysfunction.mexw64 for 64-bit Windows OS) 
Once you have these files, you should follow the steps below:
  1. Place the Model and MEX-file (mysfunction.mexext) in one directory.
  2. Create another folder in this directory with the name : modelname_targetname_rtw (This would have been the name of the generated RTW folder. For example for GRT Target, the foldername will be modelname_grt_rtw ).
  3. Place the object file (mysfunction.obj) in the above folder.
  4. Build code for your model.  

More Answers (0)

Categories

Find more on Embedded 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!