What is the difference between "slbuild" and "rtwbuild"?

35 views (last 30 days)
What is the difference between the commands "slbuild" and "rtwbuild", and how are they different from just using the 'Build' button?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Dec 2023
Edited: MathWorks Support Team on 11 Dec 2023
Several commands are available for building models in Simulink. A comparison of some of these commands is included below.
1) CTRL+B or 'Build' button
These options generate code for the parent model and all referenced models, and obey the model’s Code Generation configuration parameters. If the 'Generate Code Only' checkbox is not enabled, these methods will also build the generated code.
2) "slbuild" command
This function allows more control over the build process.
In its simplest usage – slbuild(‘modelname’) – it is equivalent to using CTRL+B or the 'Build' button.
When used with the
'ModelReferenceCoderTarget'
(called ‘ModelReferenceRTWTarget’ in R2018b and earlier) option, "slbuild" builds only model reference blocks within the specified system. As this option’s name implies, the generated code is for the target specified in the Code Generation settings (i.e. GRT, ERT, etc). This option can be helpful to see if model reference blocks will build properly without incurring the extra time of building the parent model as well. A simple way to see how this option works is to create two simple models – a ‘parent’ and ‘child’ model. The child model can be as simple as a gain block connected to an inport and outport. The parent model contains one or more model reference blocks that reference the child model. Calling "slbuild" with this option for the parent model will produce executable  for the referenced child model(s).
"slbuild"’s
‘ModelReferenceSimTarget’
option is similar to the above option, but generates code for simulation in Simulink rather than for a target.
Please note that "slbuild" cannot be used for subsystems.
3) "rtwbuild" command (no longer recommended)
"rtwbuild" is similar to "slbuild", but has fewer capabilities. "slbuild" is more general, and can be used in place of "rtwbuild".
Just like "slbuild", its simplest usage – rtwbuild(‘modelname’) – is equivalent to using CTRL+B or the 'Build' button.
"rtwbuild" and "slbuild" are indeed Simulink Coder functions, but will also work with Embedded Coder. The only difference is whether your model is set up with the grt.tlc (Simulink Coder) or ert.tlc (Embedded Coder) system target file in its configuration parameters.
For more information, please follow the below links:
Difference between Simulink Coder and Embedded Coder:
 
Starting with MATLAB R2021a, the use of the rtwbuild command is no longer recommended as it has been unified with the slbuild command. Users are encouraged to transition to slbuild for a more streamlined and comprehensive build process. rtwbuild remains functional for backward compatibility, but the unification into slbuild simplifies the build workflow by providing a single, consistent command that encompasses all capabilities previously offered by both commands.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!