The Simscape™ file is a dedicated file type in the MATLAB® environment.
It has the extension
The Simscape file contains language constructs that do not exist in MATLAB. They are specific to modeling physical objects. However, the Simscape file incorporates the basic MATLAB programming syntax at the lowest level.
Simscape files must reside in a +package directory on the MATLAB path:
For more information on packaging your Simscape files, see Organizing Your Simscape Files.
There are two types of Simscape files, corresponding to the two model types:
Domain models describe the physical domains through which component models exchange energy and data. These physical domains correspond to port types, for example, translational, rotational, hydraulic, and so on.
Component models describe the physical components that you want to model, that is, they correspond to Simscape blocks.
For example, to implement a variable area pneumatic orifice
that is different from the one in the Simscape Foundation library,
you can create a component model,
based on the standard pneumatic domain included in the Foundation
library. However, to implement a thermo-pneumatic orifice, you need
to create a domain model first,
custom pneumatic domain that accounts for gas temperature and heat
exchange), and then create the component model that references it,
as well as all the other component models based on this custom domain
and needed for modeling thermo-pneumatic systems.
Each model is defined in its own file of the same name with
.ssc extension. For example,
MyComponent.ssc. A model may be a domain
model or a component model. Each Simscape file starts with a
line specifying the model class and identifier:
ModelClass is either
Identifier is the name
of the model
A Simscape file splits the model description into the following pieces:
Interface or Declaration — Declarative section similar to the MATLAB class system declarations:
For domain models, declares variables (Across and Through) and parameters
For component models, declares nodes, inputs and outputs, parameters, and variables
Implementation (only for component models) — Describes run-time functionality of the model. Implementation consists of the following sections:
Setup — Performs initialization and setup. Executed once for each instance of the component in the top-level model during model compilation.
Structure — For composite components, describes how the constituent components' ports are connected to one another and to the external inputs, outputs, and nodes of the top-level component. Executed once for each instance of the component in the top-level model during model compilation.
Equation — For behavioral components, describes underlying equations. Executed throughout simulation.
Events — For discrete event modeling, lets you perform discrete changes on continuous variables. Executed throughout simulation.
Like the MATLAB class system, these constructs and functions act on a specific instance of the class.
Unlike the MATLAB class system:
The object is not passed as the first argument to function. This reduces syntax with no loss of functionality.
These functions have specific roles in the component lifecycle, as shown in the following diagram.
Component Instance Lifecycle
|Top-Level Model Construction|
|Top-Level Model Compilation|
|Top-Level Model Simulation|