Main Content

カスタム コンポーネント

カスタム コンポーネントを表す Simscape™ ファイルの作成

Simscape 言語では、パラメーター化、物理的接続、基となる方程式のすべて備わったテキスト ファイルとしてカスタム コンポーネントを定義できます。このページの各トピックでは、コンポーネントのパラメーター、変数、および接続の宣言に関する詳細情報を提供しています。カスタム コンポーネントの定義に関する他の側面については、方程式離散イベントおよびモード チャート、および合成コンポーネントを参照してください。

カスタム コンポーネントの作成を始めるには、カスタム コンポーネントの作成を参照してください。ここでは、一般的なワークフローの概要を説明しています。このページ下部の「参照アプリケーション コンポーネント」の下にあるトピックでは、完全なコンポーネント例を提供し、それぞれの例で使用されている手法を詳細に説明しています。


annotationsControl appearance of Simscape block based on the component
branchesEstablish relationship between component Through variables and nodes
componentComponent model keywords
inputsDefine component inputs, that is, Physical Signal input ports of block
nodesDefine component nodes, that is, conserving ports of block
outputsDefine component outputs, that is, Physical Signal output ports of block
parametersDeclare domain or component parameters
variablesDeclare domain or component variables




  • Declaring Domains and Components
    Declaration section of domain and component files: purpose, definitions, rules, member summaries.
  • Declare a Spring Component
    The following diagram shows a network representation of a mass-spring-damper system, consisting of four components (mass, spring, damper, and reference) in a mechanical rotational domain.
  • Declare Component Parameters
    Component parameters let you specify adjustable parameters for the Simscape block generated from the component file. Parameters will appear in the block dialog box and can be modified when building and simulating a model.
  • Declare Component Nodes
    Component nodes define the conserving ports of a Simscape block generated from the component file. The type of the conserving port (electrical, mechanical rotational, and so on) is determined by the type of its parent domain. The domain defines which Through and Across variables the port can transfer. Conserving ports of Simscape blocks can be connected only to ports associated with the same domain. For more information, see 物理ネットワークのモデル化の基本原則.
  • Declare Component Inputs and Outputs
    In addition to conserving ports, Simscape blocks can contain Physical Signal input and output ports, directional ports that carry signals with associated units. These ports are defined in the inputs and outputs declaration blocks of a component file. Each input or output can be defined as:
  • Declare Component Variables
    When you declare Through and Across variables in a component, you are essentially creating instances of domain Through and Across variables. You declare a component variable as a value with unit by specifying an initial value and units commensurate with units of the domain variable.
  • Define Relationship Between Component Variables and Nodes
    How to connect Through and Across variables declared in a component file to the domain Through and Across variables.
  • Declaration Functions
    Use MATLAB® functions to compute derived parameter values or initialize variables.

コンポーネント バリアント


  • Enumerations
    Specify a discrete set of acceptable values for parameters and event variables.
  • Subclassing and Inheritance
    Subclassing allows you to build component models based on other component models by extension. Subclassing applies only to component models, not domain models. The syntax for subclassing is based on the MATLAB class system syntax for subclassing using the < symbol on the declaration line of the component model:

参照アプリケーション コンポーネント

  • Model Linear Resistor in Simscape Language
    Overview of how modeling in Simscape language works, using a linear resistor as an example.
  • Mechanical Component — Spring
    The following file, spring.ssc, implements a component called spring.
  • Electrical Component — Ideal Capacitor
    The following file, ideal_capacitor.ssc, implements a component called ideal_capacitor.
  • No-Flow Component — Voltage Sensor
    The following file, voltage_sensor.ssc, implements a component called voltage_sensor. An ideal voltage sensor has a very large resistance, so there is no current flow through the sensor. Therefore, declaring a Through variable, as well as writing branches and equation statements for it, is unnecessary.
  • Grounding Component — Electrical Reference
    The easiest way to implement a grounding component is to use a connection to an implicit reference node. For an example of a component that provides an electrical ground to a circuit, see the source for the Electrical Reference block in the Foundation library:
  • Composite Component — DC Motor
    This example shows how to implement a DC motor model by means of a composite component.
  • Composite Component with Equations — RMS Voltage Sensor
    The VoltageSensorRMS component implements a voltage sensor that measures the root mean square (RMS) value of AC voltage between two electrical nodes. The declaration and equation sections of this component are similar to those of a regular voltage sensor, described in No-Flow Component — Voltage Sensor. But in order to calculate the RMS value of the measured voltage, this composite component uses the PS RMS Estimator block from the Simscape Foundation library.
  • Triggered Delay Component
    This example shows how to implement a triggered delay component.
  • Enabled Component
    This example shows how to implement a component similar to a Simulink® enabled subsystem.
  • ヒステリシスをもつスイッチ
    この例では、モード チャートと列挙を使用してコンポーネントをモデル化する方法を示します。
  • Component Variants — Series RLC Branch
    This example shows how to implement variants within a component file by using conditional sections.
  • Component Variants — Thermal Resistor
    This example shows how to implement conditional visibility of component ports, parameters, variables, and a conditional custom block icon.