Guy on Simulink

Simulink & Model-Based Design

How to Load and Save Bus Signal Data

In R2012a, the From Workspace, To Workspace, From File and To File blocks all support bus signals. This is an often requested capability, and I have been looking forward to it for a long time.

MATLAB Timeseries

In R2012a, most methods for importing and exporting data to and from a model have been standardized to use MATLAB Timeseries.

For example, if you open the dialog of the To Workspace, you will see that timeseries is now the default save format:

save formats for the To Workspace block

Using MATLAB timeseries offers a lot of advantages as I described in a previous post on the dataset logging format.

Importing Bus Data

Let's say I want to import bus data, I create a structure of timeseries:

Creating bus data

Then I specify the name of the variable or file, and the bus object in the From Workspace or From File dialog.

Configuring the From Workspace block to import bus data

and we have a model importing buses!

Model importing bus data

Exporting Bus data

To export bus data, all you need to do do is connect the bus signal to a To Workspace or To File block and ensure the block is configured to use timeseries as save format (the default).

Once the data is in the MATLAB Workspace, you can use all timeseries methods to process your data.

For example, I can quickly detrend, filter and plot a random signal "b", contained inside bus "busOut":

processing bus data using MATLAB timeseries

Processed data

Now its your turn

Are you going to include these new methods of loading and saving bus data in your workflow? Which is be best block pair for loading/saving buses? Let us know by leaving a comment here

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。