Simulink.Bus

Specify properties of buses

Description

Simulink.Bus objects, used with Simulink.BusElement objects, specify and validate the properties of a bus. When you simulate a model or update diagram, Simulink® checks whether buses connected to blocks match specified Simulink.Bus objects.

You can use a Bus object to specify signal attributes. For example, you can specify signal attributes in Inport and Data Store Memory blocks.

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

Creation

Description

example

busObject = 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.

Properties

expand all

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

Elements of the bus, specified as an array of Simulink.BusElement objects. Each BusElement object defines the name, data type, dimensions, and other properties of a signal within the 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.

ValueAction
'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. Based on the value of the DataScope property, import the data type definition from or export the data type definition to the header file. 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.

Object Functions

Simulink.Bus.cellToObjectConvert cell array containing bus information to bus objects
Simulink.Bus.createMATLABStructCreate MATLAB structures using same hierarchy and attributes as bus signals
Simulink.Bus.createObjectCreate bus objects from blocks or MATLAB structures
Simulink.Bus.objectToCellUse bus objects to create cell array containing bus information
Simulink.Bus.saveSave bus objects in MATLAB file

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 Bus object, use the Bus Editor.

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

Introduced before R2006a