Bus & Data
Generate Bus Object for Bus Creators
This function creates bus objects (Simulink.Bus) for the selected Bus Creator blocks. Each output line of the selected Bus Creator blocks must have a line name, and that name is used as the bus object name.
After you click the button, a dialog appears:
Bus Generation Methods
By checking resolved signals:
The software checks the signal name of each input to the Bus Creator block. If all signals are defined, the bus object is created using the defined signal properties. If any signal is not defined, the bus object is not created.By compiling the model:
The software compiles the model to create bus objects. See Simulink.Bus.createObject.
Code Generation Options
Here, you can configure various bus object properties.
Select Data Source
You can choose where to save the newly generated bus objects. If the model is linked to a data dictionary, you can select the main dictionary or any referenced dictionary. If the model has access to the base workspace, you can also select the base workspace.
Examples
Generate bus objects by compiling the model:
Generate bus objects by checking resolved signals:
Link Bus Signals
This function connects a Bus Selector’s named bus signals to the matching input ports of one or more selected downstream Subsystem or Model Reference blocks.
How to use: Select one Bus Selector and one or more Subsystem or Model Reference blocks, then click the button. The tool traces the Bus Selector upstream until it finds a Bus Creator or a resolved Simulink.Bus object, retrieves the bus’s element names, and routes each named element line to the same-named input port on every selected downstream block.
Requirements:
- Exactly one Bus Selector must be in the selection.
- The Bus Selector’s outport must be unconnected.
- The bus must be resolvable upstream — either via a Bus
Creator whose inputs are named, or via a
Simulink.Busobject attached to the bus line.
Example
Data Dictionary Functions
This button opens a menu for data dictionary functions. It is available in MATLAB R2016a and later versions.
The menu currently provides two functions:
- Save all data dictionary changes
- Discard all data dictionary changes
These options are available only when there are unsaved changes in any of the open data dictionaries.
Run Simulation, Generate MDF
This function simulates the model shown in the active Simulink editor and writes the logged signals to an MDF file. Open the model you want to run and enable logging for the signals you need before clicking the button. Nothing needs to be selected.
How to use:
- Click the button. A Run simulation dialog shows the name of the model about to run and its stop time. You can type a different stop time; it is used for this run only and is not written back to the model. Click Run to start, or Cancel to stop here.
- While the simulation runs, the button turns into a stop button. Click it again to stop the simulation early. You are then asked whether to Discard the partial data or Continue with it.
- When the simulation is over, the Simulation Data window opens with the logged signals.
Check the model name and stop time before starting the simulation.
View Signal Values
- Type in the filter box to narrow the signal list; the heading shows how many signals are shown out of the total.
- Move signals to the right-hand list with the arrow buttons, then click View Simulation Data to show them in the Simulation Data Inspector.
- Select one signal to see where it comes from in the model. Click the location link to open that subsystem and highlight the signal line. Signals logged by To Workspace blocks have no location.
Picking signals here is for viewing only: the MDF file always contains every logged signal.
Export to MDF
- Resample signal — resample signals at a
fixed sample interval before writing. Enter the interval in
seconds; for example,
0.01gives one sample every 10 ms. Leave this option clear to keep the original time steps. - Only resample numerical signal — when resampling is enabled, leave logical and enumerated signals at their original time steps.
Click Export to MDF and choose the file name and the MDF version in the save dialog. The default is the model name in the model folder. Three versions are available:
- MDF 4.1, compressed (
.mf4) - MDF 4.0 (
.mf4) - MDF 3.3 (
.mdfor.dat)
If you cancel the save dialog, you return to the window with your choices kept.
Generate Signal Editor from MDF Files
This function reads signals from a measurement file
(.mdf, .dat or .mf4) and
builds a Signal
Editor block that plays them back into a model. The selected
signal data is saved to a MAT file, which the Signal Editor
block reads.
Choose one measurement file at a time. What happens after you select it depends on the blocks selected in Simulink: Model blocks with unconnected inports open a mapping table; otherwise, you pick the channels by hand. Channels whose groups contain no recorded samples are omitted from the list.
Feed the Inports of Model Blocks
Select one or more Model (model reference) blocks with unconnected input ports, then click the button. Here is an example of a Model block being selected. This function only searches for unconnected inports.
- The inputs of each referenced model are read and split into
single signals: every leaf of a bus and every element of an
array becomes its own row (for example
INPUT_BUS.aorarr[0]). Array indices start at zero. - A mapping table opens. The Model inputs column lists these signals; the Selected MDF signal column is pre-filled with the MDF channel that best matches each one. Cells that are not an exact match are highlighted in amber — check them before confirming.
- Type in the filter box to find a channel. To change a match, select its cell in Selected MDF signal, pick a channel in the left-hand list and click the right arrow. The left arrow clears the selected cell. The up and down arrows are disabled in this mode because the rows follow the model inputs.
- Click OK and choose where to save the MAT file.
The tool creates a subsystem containing the Signal Editor to the left of the selected blocks. A Bus Selector connects its output to the model inports, and each signal is converted to the data type the referenced model expects.
If at least one element of an inport has a channel, the tool
builds the whole inport. Any unmapped elements of that bus or
array are fed by Ground blocks and listed in a note inside the
generated subsystem. In the example above, arr[1]
is grounded. An inport with no channels selected at all stays
unconnected; an inport that already has a line keeps its
existing connection.
Inports with the same name share a signal, even across different Model blocks. If two models use the same inport name for different signals, data types, or dimensions, the function stops and reports the conflict.
Pick Signals by Hand
- Leave the block selection empty and click the button, then choose the MDF file. This mode also opens if the selection contains no Model block with an unconnected inport.
- Type in the filter box to narrow the channel list. The heading shows the number of visible channels out of the total.
- Select the channels you need on the left and click the right arrow to add them to Selected signals to generate Signal Editor. Select a channel on the right and click the left arrow to remove it. Multiple channels can be transferred together; the up and down arrows move one selected entry within the picked list.
- Click OK, which becomes available once at least one channel is picked, and choose where to save the MAT file.
A new untitled model opens with a subsystem containing the Signal Editor, data type conversions, and a Bus Creator. In this mode, the generated signals are sorted by channel name so related bus elements stay together. Save the model and keep the MAT file at the location used when it was created: the Signal Editor reads its data from that file. Canceling the MAT-file save dialog creates no subsystem or model.