To simplify model layout, use these techniques to combine individual signals into composite signals:
A virtual or nonvirtual bus — Combine signals using a Bus Creator block and access individual signals based on name with a Bus Selector block.
An array of buses — Combine similar nonvirtual bus signals into a Vector Concatenate or Vector Concatenate block and select buses using Selector and Bus Selector blocks.
A mux — Connect signals of the same type using a Mux block and access individual signals using a Demux block.
A concatenated vector or matrix of signals — Combine signals using a Vector Concatenate or Vector Concatenate block.
Using virtual buses meets most modeling requirements for combining signals into a composite signal. Virtual buses give you flexibility for combining different types of signals. Compared to nonvirtual buses, virtual buses are simpler to use, require less memory, and usually simulate faster. For an example of using virtual buses, see Getting Started with Buses. For a comparison of approaches to creating composite signals, see Select a Composite Signal Technique.
|Bus Assignment||Replace specified bus elements|
|Bus Creator||Create bus signal from input signals|
|Bus Selector||Select signals from incoming bus|
|In Bus Element||Select bus element or entire bus that is connected to subsystem input port|
|Out Bus Element||Output signals from a subsystem as a virtual bus|
|Bus to Vector||Convert virtual bus to vector|
|Demux||Extract and output elements of virtual vector signal|
|Mux||Combine input signals of same data type and numeric type into virtual vector|
|Convert virtual bus signals into vector signals by adding Bus to Vector blocks|
|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|
Get an overview of the techniques you can use to combine signals into a composite signal.
Choose the composite signal technique that meets your modeling requirements.
Use Bus Creator and Bus Selector blocks to combine signals into virtual and nonvirtual buses and select signals from those buses.
Name, rearrange, and browse bus signals created using Bus Creator blocks. Use a bus object as the output data type.
Use In Bus Element and Out Bus Element for bus signal inputs and outputs to subsystems.
Display information about bus signals, such as paths and the kind of bus.
Identify the blocks that support bus signals as inputs.
Include a bus signal in another bus signal, creating a hierarchy of nested bus signals.
Use a Bus Assignment block to assign the values of a signal to elements of a bus. Change bus element values without adding Bus Selector and Bus Creator blocks to select bus elements and reassemble them into a bus.
All signals in a nonvirtual bus must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use a Rate Transition block to apply the same sample time to each bus element.
Specify bus element values as initial conditions for bus signals.
Modify models that use bus signals as muxes by using the Model Advisor or manually changing your model.
Streamline a model by combining nonvirtual bus signals that have the same bus type (use the same bus object) into an array of buses.
Use array of bus signals in a model, load array of bus data, and log array of bus signals.
Set up your model to use an array of buses to select signals, assign values to a signal, perform iterative processing, log and load signals, and initialize signals.
Convert an existing model that does not use arrays of buses to use arrays of buses.
Use bus signals with root-level Inport and Outport blocks, atomic subsystem nonvirtual Inports, and referenced models.
As part of simulation and code generation for S-Function blocks and Stateflow® charts, Simulink® automatically converts a virtual bus to a nonvirtual bus and nonvirtual buses to virtual buses, as necessary.
Use bus signals that cross the boundary between a model that contains a Model block and the referenced model.
Use bus signals in a library block.
Code generation for virtual and nonvirtual buses produces different results. Nonvirtual bus code generation creates a structure to represent the bus. You can control data types of initial condition structure fields.
Display interfaces to trace signals through the nested levels, annotate signal characteristics, and view units associated with signals.
Display signal attributes at load time without compiling.
Find mismatching signal attributes at load time without compiling.
Understand what bus objects are and when and how you can use them.
Create and manage bus objects using the Bus Editor.
Use functions and classes to define bus objects and bus elements, create bus objects from blocks, or create bus objects from MATLAB® data.
Change bus object and bus element properties or add and delete bus elements.
Store bus objects in a data dictionary, MATLAB file, MAT-file, or an external source file, such as a database file. Load bus objects from these files into the base workspace.
Customize the Bus Editor import and export commands by writing MATLAB functions that provide the desired capabilities. Register these functions using the Simulink Customization Manager.
Associate bus objects with models and keep track of those associations.