Simulink.BusElement

Specify properties of elements of buses

Description

A Simulink.BusElement object specifies the properties of a signal in a bus.

BusElement objects validate the properties of signals in a bus. A Simulink.Bus object contains BusElement objects. A BusElement object exists only within a Bus object. You can specify a bus object, but not a BusElement object, as a block parameter value. When you simulate a model or update diagram, Simulink® checks whether the signals in a bus connected to blocks have the properties specified by the BusElement objects. If not, Simulink halts and displays an error message.

You can use the Simulink Bus Editor (see Create and Specify Bus Objects), or MATLAB® commands (see Create Bus Objects Programmatically) to create and modify Bus objects and BusElement objects in the base MATLAB workspace.

Creation

Description

example

busElementObject = Simulink.BusElement returns a BusElement object with these property values:

              Name: 'a'
        Complexity: 'real'
        Dimensions: 1
          DataType: 'double'
               Min: []
               Max: []
    DimensionsMode: 'Fixed'
        SampleTime: -1
              Unit: ''
       Description: ''

Properties

expand all

Name of element, specified as a character vector.

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

Dimensions of element, specified as an array.

Data type of element, specified as a built-in Simulink data type or Simulink.NumericType object. Examples of built-in data types include double and uint8. You can specify a Simulink.NumericType object whose DataTypeMode property is set to a value other than 'Fixed-point: unspecified scaling'. Specifying a Bus object allows you to create Bus objects that specify hierarchical buses (that is, buses that contain other buses).

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

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

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

Sample time of element, specified as a double. The sample time is the size of the interval between times when this signal value must be recomputed. If these conditions apply, use the default value of -1:

  • The element is a bus.

  • The bus that includes this element passes through a block that changes the bus sample time, such as a Rate Transition block.

Physical unit for expressing element, specified as a character vector (for example, 'inches').

Examples

collapse all

This example shows how to create a Bus object and its associated BusElement objects in the base workspace.

Create a Bus object named CONTROL.

CONTROL = Simulink.Bus;

Create and specify properties for two BusElement objects, named VALVE1 and VALVE2.

valve1 = Simulink.BusElement;
valve1.Name = 'VALVE1';
valve1.Dimensions = 1;
valve1.DimensionsMode = 'Fixed';
valve1.DataType = 'double';
valve1.SampleTime = -1;
valve1.Complexity = 'real';

valve2 = Simulink.BusElement;
valve2.Name = 'VALVE2';
valve2.Dimensions = 1;
valve2.DimensionsMode = 'Fixed';
valve2.DataType = 'double';
valve2.SampleTime = -1;
valve2.Complexity = 'real';

Assign the elements to the CONTROL Bus object.

CONTROL.Elements = [valve1 valve2];

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

Not recommended starting in R2019b

Not recommended starting in R2016b

Introduced before R2006a