This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Custom Components

Write Simscape™ files to represent custom components

Examples and How To

Complete Components

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.

Grounding Component — Electrical Reference

The easiest way to implement a grounding component is to use a connection to an implicit reference node.

Composite Component — DC Motor

This example shows how to implement a DC motor model by means of a composite component.

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.

Switch with Hysteresis

This example shows how to model a component by using mode charts and enumerations.

Component Variants — Series RLC Branch

This example shows how to implement variants within a component file by using conditional sections.

Component Declarations and Branches

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 Variables

When you declare Through and Across variables in a component, you are essentially creating instances of domain Through and Across variables.

Declare Component Parameters

Component parameters let you specify adjustable parameters for the Simscape block generated from the component file.

Declare Component Nodes

Component nodes define the conserving ports of a Simscape block generated from the component file.

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.

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.

Component Setup

Validate Parameters

The setup function validates parameters using simple if statements and the error function.

Compute Derived Parameters

The setup function can override parameters by assigning to them.

Set Initial Conditions

As you declare variables, values that you assign to them are their initial conditions.


What Is the Simscape Language?

Brief overview of the modeling language and its purpose.

Typical Simscape Language Tasks

Overview of the typical Simscape language workflows, with links to background information and examples.

Simscape File Types and Structure

Overview of the Simscape file types and structure.

Creating Custom Components

Component types, file structure, high-level workflow.

Declaring Domains and Components

Declaration section of domain and component files: purpose, definitions, rules, member summaries.


Specify a discrete set of acceptable values for parameters and event variables.

Declaration Functions

Use MATLAB® functions to compute derived parameter values or initialize variables.

Defining Component Setup

The setup section of a Simscape file consists of the function named setup.

Defining Component Variants

Use conditional sections to define variants within component file.

Working with Domain Parameters

The purpose of domain parameters is to propagate the same parameter value to all or some of the components connected to the domain.

Attribute Lists

The attributes appear in an AttributeList, which is a comma separated list of pairs, as defined in the MATLAB class system grammar.

Subclassing and Inheritance

Subclassing allows you to build component models based on other component models by extension.

Was this topic helpful?