Main Content

Declaring Member Components

A components declaration block begins with a components keyword and is terminated by an end keyword. This block 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).

When declaring a member component, you have to associate it with an existing component file, either in the Simscape™ Foundation libraries or in your custom namespace. You need to refer to the component name using the full path starting with the top namespace folder. For more information on packaging your Simscape files, see Building Custom Block Libraries.

The following 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 namespace folder is +foundation. It contains a subnamespace +mechanical, with a subnamespace +rotational, which in turn contains the component file spring.ssc.

If you want to use your own customized rotational spring called spring.ssc and located at the top level of your custom namespace folder +MechanicalElements, the syntax would be:

components(ExternalAccess=observe)
    rot_spring = MechanicalElements.spring;
end

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

Related Examples

More About