This example shows how to generate code for a Simulink model that contains an S-Function for which you have the object file. Using the S-Function object file is one technique to protect your model intellectual property (IP). Alternatively, you may use shared libraries, static libraries, or a Simulink® Protected model for IP protection, etc.
Given that the model code must run on the SimWB real-time host, which uses a Linux platform, this example focuses on the Linux workflow. You must work through this example on an instance of MATLAB® running on a MATLAB- and SimWB-supported Linux platform.
In this example, we use the Simulink® Coder feature that generates an S-Function out of a subsystem.
The model used is <MLTOOLKITROOT>/examples/pythagoras.slx.
This model was created using MATLAB 8.2 (R2013b).
The steps from this example were also verified in MATLAB 9.1 (R2016b).
To check the Linux distribution installed on the SimWB server, execute the following at a terminal:
lsb_release -a
The end-user must provide the output of these commands to the vendor, so they can prepare their system appropriately.
Some options for creating a virtual machine for free are as follows:
<MLTOOLKITROOT>/examples/pythagoras.slx.help packSFuncIP.packSFuncIP('pythagoras','calc_hypotenuse');
A file called pythagoras_distributable.zip will be created in the current work directory. The vendor
provides this zipped file to the end-user. The file does not contain the source code for S-Function, but instead
packages:
Upon receiving the pythagoras_distributable.zip file, use the following steps to simulate the S-Function in Simulink and generate SimWB-compatible code for the model.
./pythagoras_grt_rtw/calc_hypotenuse_sf.o
!touch calc_hypotenuse_sf.c
!touch pythagoras_grt_rtw/calc_hypotenuse_sf.o
Simulink®, developed by MathWorks, is a graphical modeling environment.