Hi Daniel.
There are two possible ways to create a single protected component for Simscape subsystem with nested subsystems:
- A single protected component for the subsystem can be created using the “Simscape Component” block available in Simulink “Utilities” library. The protected subsystem code (“.sscp”) file must be provided to the block parameters, and it works with subsystems with nested subsystems as well. You can run the following command in the command window of MATLAB R2018b to the learn more about the block:
web(fullfile(docroot, 'physmod/simscape/ref/simscapecomponent.html'))
- Alternatively, a single component library file for the subsystem can be created using the command “ssc_build”. The protected files must be first placed inside a package folder, with the name “+package_name”. The command “ssc_build package_name” can then be used to create a single protected component library file for the Simscape subsystem. You can run the following command in the command window to know more about “ssc_build”:
web(fullfile(docroot, 'physmod/simscape/ref/ssc_build.html'))
However, slight modifications must be done in the subsystem code file before protecting the code files. In the code, the paths of the nested subsystems in the “components” section must be edited to match the package folder structure. You can run the following command in the command window to understand the workflow to create components from Simscape subsystems and editing the subsystem code (“.ssc”) file:
web(fullfile(docroot, 'physmod/simscape/lang/converting-subsystems-into-composite-components.html'))
I hope this helps with your query.