Simulink.BusElement

Specify properties of elements of buses

Description

A Simulink.BusElement object is an element of a Simulink.Bus object. It validates the properties of a signal in a bus.

BusElement objects exist only within the Bus object. You can specify a Bus object, but not a BusElement object, as a data type.

When you simulate or update a model, Simulink® checks whether the signals in a bus have the properties specified by the corresponding BusElement objects.

To create and modify Bus and BusElement objects in the base workspace or a data dictionary, you can use the Bus Editor or MATLAB® commands. You cannot store Bus objects in model workspaces.

Creation

Description

example

be = Simulink.BusElement returns a BusElement object with default property values.

Properties

expand all

Name of element, specified as a character vector.

Note

To validate the properties of a signal against a BusElement object, the signal name must be a valid identifier that starts with an alphabetic character or underscore (_), followed by alphanumeric characters or underscores.

Data Types: char | string

Numeric type of the element, specified as 'real' or 'complex'.

Data Types: char | string

Dimensions of element, specified as a scalar or vector.

Data Types: double

Data type of element, specified as a built-in Simulink data type, a Simulink.NumericType object, or a Simulink.Bus object.

Examples of built-in data types include double and uint8. For more information, see Data Types Supported by Simulink.

You can specify a Simulink.NumericType object whose DataTypeMode property is set to a value other than 'Fixed-point: unspecified scaling'.

Specifying a Simulink.Bus object allows you to create Bus objects that specify hierarchical buses (that is, buses that contain other buses).

Data Types: char | string

Minimum value of the element, specified as a scalar. This value must be a finite real double scalar or, if the element is a bus, the value must be empty, [].

Data Types: double

Maximum value of the element, specified as a scalar. This value must be a finite real double scalar or, if the element is a bus, the value must be empty, [].

Data Types: double

Specify how to handle size of element, specified as 'Fixed' or 'Variable'.

Data Types: char | string

Physical unit for expressing element, specified as a character vector.

Example: 'inches'

Data Types: char | string

Bus element description, specified as a character vector. Use the description to document information about the BusElement object, such as the kind of signal it applies to. This information does not affect Simulink processing.

Data Types: char | string

Examples

collapse all

Create a hierarchy of Bus objects using arrays. Array indexing lets you create and access multiple elements in an array. Dot notation lets you access property values.

Create two BusElement objects, named Chirp and Sine, in the base workspace.

elems(1) = Simulink.BusElement;
elems(1).Name = 'Chirp';

elems(2) = Simulink.BusElement;
elems(2).Name = 'Sine';

Create a Bus object, named NestedBus, that uses the elements defined in the elems array.

NestedBus = Simulink.Bus;
NestedBus.Elements = elems;

Create two more BusElement objects, named NestedBus and Step. To have NestedBus represent a Bus object, specify a Bus object data type.

clear elems

elems(1) = Simulink.BusElement;
elems(1).Name = 'NestedBus';
elems(1).DataType = 'Bus: NestedBus';

elems(2) = Simulink.BusElement;
elems(2).Name = 'Step';

Create the bus at the top of the bus hierarchy that uses the elements defined in the elems array.

TopBus = Simulink.Bus;
TopBus.Elements = elems;

You can view the created objects in the Bus Editor.

buseditor

Alternatives

To interactively create a BusElement object, use the Bus Editor.

To create BusElement objects from blocks in a model, MATLAB data, and external C code, see Create Bus Objects Programmatically.

Compatibility Considerations

expand all

Errors starting in R2020b

Not recommended starting in R2016b

Introduced before R2006a