Main Content

Simulink.BusElement

Specify properties of elements of buses

Description

A Simulink.BusElement object is an element of a Simulink.Bus object that validates the properties of an element in a bus. When you simulate or update a model, Simulink® checks whether the properties specified by the BusElement object match the properties specified by the corresponding bus elements.

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

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

Creation

You can create a BusElement object in multiple ways.

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.

To use symbolic dimensions in generated code, see Implement Symbolic Dimensions for Array Sizes in Generated Code (Embedded Coder).

Data Types: double

Data type of element, specified as a character vector or string scalar.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.

You can specify any of these options:

  • Built-in Simulink data type — For example, specify 'single' or 'uint8'. See Data Types Supported by Simulink.

  • Fixed-point data type — Use the fixdt function. For example, specify 'fixdt(1,16,0)'.

  • Enumerated data type — Use the name of the type preceded by Enum:. For example, specify 'Enum: myEnumType'.

  • Bus data type — Use the name of the Simulink.Bus object preceded by Bus:. For example, specify 'Bus: myBusObject'.

  • Value type — Use the name of the Simulink.ValueType object preceded by ValueType:. For example, specify 'ValueType: windVelocity'.

  • Custom data type — Use a MATLAB expression that specifies the type. For example, 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).

When you specify a Simulink.ValueType or Simulink.Bus object, the object defines more than the data type. The object also defines properties such as Min, Max, and Unit. The property values specified by the ValueType object override the corresponding property values specified by a block. For example, suppose a block sets Unit to ft/s. When the Data type of the block specifies a ValueType object that has m/s as its unit, the block uses m/s instead of ft/s.

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.

For more information, see Unit Specification in Simulink Models.

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 Simulink.Bus objects using arrays of Simulink.BusElement objects.

Create an array that contains 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';

Array indexing lets you create and access the elements of the array. Dot notation lets you access property values of the elements.

Create a Bus object, named Sinusoidal, that contains the elements defined in the elems array.

Sinusoidal = Simulink.Bus;
Sinusoidal.Elements = elems;

To create a hierarchy of Bus objects, create another Bus object to reference the Bus object named Sinusoidal.

Create an array that contains two BusElement objects, named NestedBus and Step. Specify the Bus object named Sinusoidal as the data type of the NestedBus element.

clear elems

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

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

Create a Bus object, named TopBus, that contains the elements defined in the elems array.

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

You can view the hierarchy of the created objects in the Type Editor.

typeeditor

Version History

Introduced before R2006a

expand all