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, the software checks whether the properties specified by the object match the properties specified by the corresponding bus elements.

You can specify a bus object, but not a bus element object, as a data type.

To create and modify Simulink.Bus and Simulink.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 Simulink.BusElement object in multiple ways.

  • To interactively create a Simulink.BusElement object, use the Type Editor or Model Explorer.

  • To programmatically create a default Simulink.BusElement object, use the Simulink.BusElement function (described here).

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

Description

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

example

Properties

expand all

Name of element, specified as a character vector.

To validate the properties of a signal against a Simulink.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'.

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType or Simulink.Bus object. The software uses the complexity specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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).

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType object. The software uses the dimensions specified by the Simulink.ValueType object instead.

Data Types: double

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

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. 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, optionally preceded by Bus:. For example, specify 'myBusObject' or '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 as the data type, some properties of the Simulink.BusElement object are ignored. For example, the Min, Max, and Unit properties of the Simulink.BusElement object are ignored. The software uses the corresponding properties of the Simulink.ValueType object or Simulink.BusElement objects in the Simulink.Bus object instead.

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, [].

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType or Simulink.Bus object. The software uses the minimum values specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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, [].

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType or Simulink.Bus object. The software uses the maximum values specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

Data Types: double

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

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType or Simulink.Bus object. The software uses the dimensions modes specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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'

Dependencies

The software ignores the value of this property when DataType specifies a Simulink.ValueType or Simulink.Bus object. The software uses the units specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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