MATLAB: Can I provide pre-compiled proprietary S-Functions with a Simulink model to be used in Real-Time Workshop 5.0 (R13)

ccodecompileddllmexmodelobjectpreproprietaryrtws-functionsimulinksimulink coder

I have a Simulink model which contains a proprietary C-MEX S-Function. I would like to distribute the S-Function in proprietary form so that it can be used with Real-Time Workshop.

Best Answer

This is not a trivial task, since it requires an extensive knowledge of Real-Time Workshop 5.0 (R13) code generation.
To do this, you will need to do the following:
1. Write a TLC-file that calls your proprietary S-functions to generate code from the S-Fcn block.
2. Provide the object files for each platform/compiler combination that the end users might be using.
3. Write a custom template make file (.tmf) which links your object files to the RTW executable. You can use one of the make files shipped with MATLAB and modify it as necessary.
For more information execute the following commands in the MATLAB command window:
Code Generation and the Build Process
web([docroot '/toolbox/rtw/rtw_ug/make2.html'])
Customizing the Build Process
web([docroot '/toolbox/rtw/rtw_ug/target10.html'])
For information on how to write TLCs refer to the following section in the documentation:
Target Language Compiler (Real-Time Workshop)
The 'timestwo' s-function demo model 'sfcndemo_timestwo' uses the TLC file 'timestwo.tlc', which is a good-starting point for writing TLCs. To open this model, type 'sfcndemo_timestwo' at the MATLAB Command Prompt. This model has a link to the 'timestwo.tlc' file.
For further information on various TLC directives and built-in functions, refer to the following section:
Directives and Built-In Functions (Real-Time Workshop)