Store and Load Bus Objects

You can store bus object objects in a variety of ways.

FormatWhen to Use

In a data dictionary

For large model componentization

As a MATLAB® code file

For traceability and model differencing using MATLAB code

As a MATLAB data file (MAT-file)

For faster bus loading and saving

In a database or other external data source

For comparing bus interface information with design documents stored in an external data source.

Data Dictionary

You can use the Model Explorer to create a new data dictionary that includes bus objects and link it to a model. For details, see Migrate Single Model to Use Dictionary.

MATLAB Code Files

You can read and save bus data with MATLAB code files.

To save all bus objects (instances of the Simulink.Bus class) in the MATLAB base workspace to a MATLAB code file, use one of the following approaches:

To save variables from the base workspace to a MATLAB code file, use the Simulink.saveVars command. The file containing the variables is formatted to be easily understood and editable. Running the file restores the saved variables to the base workspace.

For traceability, consider using a clearly named separate file for each model.

MATLAB Data Files (MAT-Files)

You can load bus objects in MATLAB data files (MAT-files), using one of the following approaches:

Loading large data from MAT-files is faster than loading from MATLAB code files.

Database or Other External Source Files

You can capture bus interface information in a database or other external source, and use scripts and Database Toolbox™ functionality to read that information into MATLAB.

You can use sl_customization.m to customize the Bus Editor to import bus data from a database or other external source. For details, see Customize Bus Object Import and Export.

Related Examples

Was this topic helpful?