Main Content

components

Declare member components included in composite component

Parent Section: component

Syntax

components(ExternalAccess=observe)
    a = package_name.component_name;
end

Description

components begins a components declaration block, which is terminated by an end keyword. This block, used in composite models only, contains declarations for member components included in the composite component. A components declaration block must have its ExternalAccess attribute value set to observe (for more information on member attributes, see Attribute Lists).

Each member component is defined by assignment to an existing component file. See Declaring Member Components for more information.

The following syntax defines a member component, a, by associating it with a component file, component_name. package_name is the full path to the component file, starting with the top package directory. For more information on packaging your Simscape™ files, see Building Custom Block Libraries.

components(ExternalAccess=observe)
    a = package_name.component_name;
end

After you declare all member components, specify how their 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.

Once you declare a member component, you can use its parameters and variables in the equation section of the composite component file. If you want a parameter of the member component to be adjustable, associate it with the top-level parameter of the composite component. See Parameterizing Composite Components for more information.

You can also use for loops to declare an array of member components and specify the component connections. For more information, see Component Arrays.

Examples

expand all

This example includes a Rotational Spring block from the Simscape Foundation library in your custom component:

components(ExternalAccess=observe)
    rot_spring = foundation.mechanical.rotational.spring;
end

The name of the top-level package directory is +foundation. It contains a subpackage +mechanical, with a subpackage +rotational, which in turn contains the component file spring.ssc.

Once you declare a member component, use its identifier (rot_spring) to refer to its parameters, variables, nodes, inputs, and outputs, as they are defined in the member component file. For example, rot_spring.spr_rate refers to the Spring rate parameter of the Rotational Spring block.

Version History

Introduced in R2012b