component
Component model class definition
Parent Section: none (top-level)
Syntax
component ComponentName
... % Declaration section
... % Implementation section
end
Description
component begins the component model class definition, which is
terminated by an end keyword. Only blank lines, comments, and
import statements can precede component. You
must place a component model class definition in a file of the same name with a file
name extension of .ssc.
A component file consists of a declaration section, with one or more member declaration blocks, followed by implementation sections, such as branches, equations, events, and so on. The order of these sections does not matter.
Note
The file can contain multiple instances of declaration blocks or implementation
sections of the same type, with the exception of the
setup section. There may be no more than
one setup section per component. However,
starting in R2019a, using setup is not
recommended. For better alternatives, see setup is not recommended.
The declarations section may contain any of the following member declaration blocks:
nodesbegins a nodes declaration block, which is terminated by anendkeyword. This block contains declarations for all the component nodes, which correspond to the conserving ports of a Simscape™ block generated from the component file. Each node is defined by assignment to an existing domain. See Declare Component Nodes for more information.inputsbegins an inputs declaration block, which is terminated by anendkeyword. This block contains declarations for all the inputs, which correspond to the input Physical Signal ports of a Simscape block generated from the component file. Each input is defined as a value with unit. See Declare Component Inputs and Outputs for more information.outputsbegins an outputs declaration block, which is terminated by anendkeyword. This block contains declarations for all the outputs, which correspond to the output Physical Signal ports of a Simscape block generated from the component file. Each output is defined as a value with unit. See Declare Component Inputs and Outputs for more information.parametersbegins a component parameters declaration block, which is terminated by anendkeyword. This block contains declarations for component parameters. Parameters will appear in the block dialog box when the component file is brought into a block model. Each parameter is defined as a value with unit. See Declare Component Parameters for more information.variablesbegins a variables declaration block, which is terminated by anendkeyword. This block contains declarations for all the variables associated with the component. Variables will appear on the Variables tab of a block dialog box when the component file is brought into a block model.Variables can be defined either by assignment to an existing domain variable or as a value with unit. See Declare Component Variables for more information.
componentsbegins a member components declaration block, which is terminated by anendkeyword. This block, used in composite models only, contains declarations for member components included in the composite component. Each member component is defined by assignment to an existing component file. See Declaring Member Components for more information.intermediatesbegins a declaration block of named intermediate terms, which is terminated by anendkeyword. This block contains declarations of intermediate terms that can be reused in anyequationssection of the same component or of an enclosing composite component. See Using Intermediate Terms in Equations for more information.
branches begins the branches section, which is terminated by an
end keyword. This section establishes relationship between the
Through variables of the component and the domain. Relationship between the Across
variables is established in the equation section. See Define Relationship Between Component Variables and Nodes for more
information.
connections begins the structure section, which is terminated by an
end keyword. This section, used in composite models only,
contains information on how the constituent components’ ports are connected to one
another, and to the external inputs, outputs, and nodes of the top-level component. See
Specifying Component Connections for
more information.
equations begins the equation section, which is terminated by an
end keyword. This section contains the equations that define how
the component works. See Defining Component Equations for more
information.
events begins the events section, which is terminated by an
end keyword. This section manages the event updates. See Discrete Event Modeling for more information.
annotations begins the annotations section, which is terminated by
an end keyword. This section lets you provide annotations in a
component file that control various cosmetic aspects of a Simscape block generated from this component. See annotations for more information.
For component model attributes, as well as declaration member attributes, see Attribute Lists.
Examples
Version History
Introduced in R2008b