Main Content

addComponent

Class: simscape.multibody.Multibody
Namespace: simscape.multibody

Add component object to Multibody object

Since R2022a

Description

addComponent(mb,componentName,C) adds a component object, C, to the top level of the simscape.multibody.Multibody object, mb. Use the componentName argument to specify the name of the new component object in the mb object.

Note that the addComponent method adds only a copy of a component object to a Multibody object, and any subsequent changes to the original component object do not affect the copy. Therefore, you must completely configure a component object before adding the object to a Multibody object.

By default, the newly added component object does not connect to other objects in the Multibody object. See addConnector, connect, and connectVia to learn how to connect component objects in a Multibody object.

Input Arguments

expand all

Multibody system, specified as a simscape.multibody.Multibody object.

Name of the new component object in the Multibody object, specified as a string scalar or character vector. The name must be unique among the names of component objects at the top level of the Multibody object. In addition, the name must be a valid MATLAB® identifier. You can use the isvarname function to check if the name is a valid identifier.

Example: "NE_Lower_Joint"

Component object to add to the simscape.multibody.Multibody object, specified as an object of a subclass of the simscape.multibody.Component abstract class, such as simscape.multibody.Multibody, simscape.multibody.RigidBody, or simscape.multibody.RigidTransform.

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes.

Version History

Introduced in R2022a