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 theSimulink.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.
Syntax
Description
returns a bus element
object with default property values.be
= Simulink.BusElement
Properties
Name
— Name of element
'a'
(default) | character vector | string scalar
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
Complexity
— Numeric type of element
'real'
(default) | 'complex'
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
— Dimensions of element
1
(default) | scalar | vector
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
DataType
— Data type of element
'double'
(default) | character vector | string scalar
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 . 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 byBus:
. For example, specify'myBusObject'
or'Bus: myBusObject'
.Value type — Use the name of the
Simulink.ValueType
object preceded byValueType:
. 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 whoseDataTypeMode
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
Min
— Minimum value of element
[]
(default) | scalar
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
Max
— Maximum value of element
[]
(default) | scalar
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
DimensionsMode
— Specify how to handle size of element
'Fixed'
(default) | 'Variable'
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
Unit
— Physical unit for expressing element
''
(default) | character vector | string scalar
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
Description
— Bus element description
''
(default) | character vector | string scalar
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
Create Bus Objects from Bus Element Objects
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 R2006aR2023b: Simulink.ValueType
objects do not override description of parent
When you specify a Simulink.ValueType
object as the data type of a
Simulink.BusElement
object, the value type object no longer overrides the description
of the Simulink.BusElement
object.
R2020b: Simulink.BusElement
objects no longer support the SampleTime
property
The SampleTime
property of Simulink.BusElement
objects is no longer supported.
BusElement
objects that specify a sample time cause an error during
compile. To remove the sample time specification from a BusElement
object,
set its SampleTime
to -1
.
Simulink.Bus.cellToObject
continues to accept cell arrays that
specify sample time for bus elements. Simulink.Bus.objectToCell
,
Simulink.Bus.save
, and Simulink.Bus.createObject
continue to return cell arrays or arrays that include the sample time when it is noninherited.
When the sample time is inherited (-1
), they omit it. Similarly, the
Type Editor and Model Explorer omit the sample time when it is
inherited.
To specify the sample time for an element of a bus, use the
SampleTime
block parameter of corresponding blocks. For example,
you can use In Bus Element, Out Bus Element, and Signal
Specification blocks to specify sample time.
R2016b: Simulink.BusElement
objects will no longer support the SamplingMode
property
The SamplingMode
property of Simulink.BusElement
objects has been removed. Scripts that use the SamplingMode
property of
Simulink.BusElement
objects continue to work. The
Simulink.Bus.cellToObject
function continues to require the
SamplingMode
field. The
Simulink.Bus.objectToCell
function continues to include the
sampling mode in the output cell arrays. When you save Simulink.Bus
object
definitions to functions that use cell arrays, the cell arrays continue to include the
sampling mode.
In a future release, support for the SamplingMode
property will be
removed.
To specify whether a signal is sample-based or frame-based, define the sampling mode of input signals at the block level instead of at the signal level.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)