This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Simulink.Bus class

Package: Simulink

Specify properties of bus signal


Objects of the Simulink.Bus class, used with objects of the Simulink.BusElement class, specify the properties of a bus signal. Bus objects validate the properties of bus signals. When you simulate a model or update diagram, Simulink® checks whether the buses connected to the blocks have the properties specified by the bus objects. If not, Simulink halts and displays an error message. For a complete list of blocks that support using a bus object as a data type, see When to Use Bus Objects.

You can use the Simulink Bus editor or MATLAB® commands to create and modify bus objects in the base MATLAB workspace. You cannot store a bus object in a model workspace.

When you use the Bus Editor, you create Simulink.Bus and Simulink.BusElement objects in the base workspace or the associated Simulink data dictionary.

Also, you can use a bus object to specify the attributes of a signal (for example, at the root level of a model or in a Data Store Memory block).


busObj = Simulink.Bus returns a bus object with these property values:

    Description: ''
      DataScope: 'Auto'
     HeaderFile: ''
      Alignment: -1
       Elements: [0×0 Simulink.BusElement]

The name of the bus object is the name of the MATLAB variable to which you assign the bus object. You can set individual properties after you construct the bus object.

Output Arguments

expand all

Bus object, returned as a Simulink.Bus object.


expand all

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

Bus elements, specified as an array of Simulink.BusElement objects. Each bus element object defines the name, data type, dimensions, and other properties of the signal within a bus.

Data type definition mode in generated code, specified as 'Auto', 'Exported', or 'Imported'. This property specifies whether during code generation the data type definition is imported from, or exported to, the header file specified with the HeaderFile property.

'Auto' (default)

Import the data type definition from the specified header file. If you do not specify the header file, export the data type definition to the default header file.

'Exported'Export the data type definition to the specified header file or default header file.
'Imported'Import the data type definition from the specified header file or default header file.

C header file used with data type definition, specified as a character vector. The header file is the file to import the data type definition from or export the data type definition to (based on the value of the DataScope property. The Simulink Coder™ software uses this property for code generation. Simulink software ignores this property.

By default, the generated #include directive uses the preprocessor delimiter " instead of < and >. To generate the directive #include <myTypes.h>, specify HeaderFile as <myTypes.h>.

Data alignment boundary, specified as an integer, in number of bytes. The Simulink Coder software uses this property for code generation. Simulink software ignores this property.

The starting memory address for the data allocated for the bus is a multiple of the Alignment setting. If the object occurs in a context that requires alignment, you must specify an Alignment value with a positive integer that is a power of 2, not exceeding 128.





Convert cell array containing bus information to bus objects


Create MATLAB structures using same hierarchy and attributes as bus signals


Create bus objects from blocks or MATLAB structures


Use bus objects to create cell array containing bus information

Save bus objects in MATLAB file

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects (MATLAB).


collapse all

Create the CONTROL bus object and its bus elements. The bus objects are stored in the base workspace.

clear elems;
elems(1) = Simulink.BusElement;
elems(1).Name = 'VALVE1';
elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'double';
elems(1).SampleTime = -1;
elems(1).Complexity = 'real';

elems(2) = Simulink.BusElement;
elems(2).Name = 'VALVE2';
elems(2).Dimensions = 1;
elems(2).DimensionsMode = 'Fixed';
elems(2).DataType = 'double';
elems(2).SampleTime = -1;
elems(2).Complexity = 'real';

CONTROL = Simulink.Bus;
CONTROL.Elements = elems;

This script is similar to the file that you get by saving a bus object to a MATLAB file and choosing the Object format.


You can use the Bus Editor to create interactively a bus object and its bus elements. For details, see Create Bus Objects with the Bus Editor.

Programmatically, you can create bus objects from:

Introduced before R2006a