MATLAB: What is the difference between “slbuild” and “rtwbuild”
Embedded Coder
Related Question
- I have a parameter that is used only inside of a variant subsystem. How to make sure that in the generated code this parameter is only defined if the variant is active
- Is there a difference in code generation when running a SIL simulation with Model blocks in R2013a
- Unable to find ‘solver_zc.h’ header file in generated code from Embedded Coder
- Do I get a build error in the PARROT minidrone model
- How to use PackNGo without naming dependencies on the current directory
- How to make each input and output be a separate structure in Embedded coder code
Best Answer
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
"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:
https://www.mathworks.com/matlabcentral/answers/232137-difference-between-simulink-coder-and-embedded-coder