Generating Custom Blocks from Simscape Component Files
After you have created the textual component files, you need to convert them into Simscape™ blocks to be able to use them in block diagrams. There are two mechanisms that let you do this:
Selecting Component File Directly from Block — Use the Simscape Component block, which you can find in the Utilities library, and point it to a Simscape component file. The block instantly acquires the properties based on the source component file: name, description, parameters, variables, appropriate ports and the custom icon image (if available). If you modify the underlying source file, the block reflects these changes. If you point the block to a different component file, the block properties change accordingly, to reflect the new source.
Use this method to quickly deploy a single component file, to try out different variants of a component in your model, or to iterate on a component definition and get instant feedback.
Building Custom Block Libraries — Generate a custom block library from a namespace containing Simscape component files. The namespace hierarchy determines the resulting library structure. You can customize the library name and appearance and provide annotation.
Use this method to generate reusable custom block libraries.
Related Examples
- Deploy a Component File in Block Diagram
- Switch Between Different Source Components
- Prototype a Component and Get Instant Feedback
- Create a Custom Block Library
- Customize Block Display