User`s guide
S-Function Code Format
12-19
functionality of the sfun model. The picture below shows the sfun_sf block
embedded in a new model.
After you have placed the RTW S-Function block inside a model, you can try
out several different inputs and measure the response of the original model.
The speed at which the S-Function block executes is faster than the original
model. This difference in speed will become more pronounced for larger and
more complicated models
• Sharing the model without providing the source code — To protect your
proprietary models or algorithms, you can generate an S-function from them
andthenonlyprovidethebinary
.dll or MEX-file object.
• Reusing code - You can incorporate multiple instances of one model inside
another without replicating the code for each instance. Each instance will
continue to maintain its own unique data.
You can generate an executable by using the real-time or real-time malloc code
formats for a model that contains S-functions generated by the Real-Time
Workshop. You cannot use the embedded-C format since it requires inlined
S-functions. Also, you can place a generated S-Function block in another model
which you can then be generated with the S-function format again, effectively
allowing any level of nested S-functions.
Note that sample times propagation for the S-function code format is slightly
different from the other code formats. An RTW S-Function block will inherit its
sampletimefromthemodelinwhichitisplacedifnoblocksintheoriginal
model specify their sample times.