Contenido principal

Component-Based Modeling in Simulink

Component-based modeling helps organizations develop Simulink® models that consist of many functional pieces. Each Simulink component you create is a piece of your design that has an interface and facilitates assembly of a system or a larger component. Useful components have a well-defined scope, perform functionality defined by requirements, and form part of a larger system.

Components can enable:

  • Team-based development — Reduce file contention and elaborate components independently through well-defined interfaces.

  • Reduced design complexity — Each component solves smaller problems.

  • Reuse — Reuse algorithms and environment models within a project and across multiple projects.

  • Unit testing — Eliminate retesting for unchanged components and reduce the cost of verification.

  • Performance benefits that scale — Reduce memory usage and the time required to load and simulate models.

  • Variants — Choose among multiple implementations of a component.

  • Intellectual property protection — Limit functionality and content visibility for components that you share with third parties.

To integrate your existing Simulink components, components authored using third-party tools, and your MATLAB®, C/C++, or Python® code into Simulink, see Choose Tools to Integrate Existing Components and MATLAB, C/C++, or Python Code into Simulink.

Should You Create Simulink Components?

Considering the work required to define and manage components, you should use component-based modeling only when the benefits outweigh the cost.

Separating an existing Simulink model into components is analogous to taking a large piece of code (C, Java®, or MATLAB code) and breaking it down into multiple functions. The conversion can require significant effort and extensive modifications if the design is not modular from the beginning.

Considering model scalability and potential requirements upfront makes separating a Simulink model into components easier. Identifying components upfront can help you avoid these difficulties:

  • Poor component definition — The scope of subsystems that are grown over time can fail to meet component requirements. For example, they might contain too much or too little functionality to be reused, to generate code that integrates with legacy functionality, or to support hardware-in-the-loop tests.

  • Merge conflicts — If additional engineers begin to work on a model that was originally designed for development by a single engineer, they can encounter time-consuming and error-prone merges.

  • Artificial algebraic loops — If a single engineer develops a model from the bottom up, they are likely to group blocks into subsystems as model complexity increases. The subsystems within the model are likely visual groupings that do not affect model execution. When you make these subsystems atomic, or convert them to referenced models, you can introduce artificial algebraic loops that can be difficult to diagnose and resolve.

Components are also useful when a design becomes too complicated for one person to manage all of the details. For example, a complicated model can be a model that has:

  • Thousands of blocks

  • Hundreds of logical decisions

  • Multiple variant configurations of the same functionality

Projects and source control can help you manage components. For more information, see What Are MATLAB Projects in Simulink? and Configuration Management.

To design your system architecture before implementing functionality using Simulink components, see Compose and Analyze Systems Using Architecture Models (System Composer).

Define Simulink Components

1. Explore Types of Simulink Components

Identify Simulink components that align with your high-level modeling requirements.

2. Compare Capabilities of Simulink ComponentsInvestigate which types of Simulink components meet your low-level modeling requirements.
3. Define Interfaces and Manage Data of Simulink ComponentsConfigure design attributes at interfaces and manage data for Simulink components.