Create Bus Data for Models with Root-Level Bus Inputs

Convert a matrix of data into a Simulink.TsArray according to the root-level bus object definition.
ダウンロード: 895
更新 2016/9/1

ライセンスの表示

A common task in Simulink is to test a certain component of a larger model. With large-scale modeling, such componentization is often accomplished through the use of model reference. These large models also often use bus signals to organize large amounts of signals in the model. The situation at hand is the desire to unit test one of these components in an open-loop sense, driving that component with data from another simulation or from real world (non-simulated) data. Often this data is simply a matrix of data, columns of variables, rows of data. Making this data work with root-level bus inputs in a Simulink model is sometimes a challenge.
The root cause of this challenge has to do with an understanding of Bus Objects. Assume there is a root-level inport which is associated with a bus object "INPUT_BUS." In Simulink, and in code generated by RTW-EC, a bus object is a data type, analagous to a struct definition in C. So the issue is that the root level inport is expecting data of type INPUT_BUS. Unfortunately, the data you’re getting extrenally and importing into Matlab is often a matrix of doubles of size mxn. As such, this data needs to be converted from the double precision matrix into type INPUT_BUS.

One way to accomplish this is to manipulate the data in Matlab to create a Simulink.TsArray object comprised of Simulink.TimeSeries objects that corresponds with the bus object INPUT_BUS. This is probably the cleanest way, as this is how Simulink understands data in buses defined by bus objects. The best example of this is if you log a bus signal using signal logging, the data in the workspace would be a Simulink.TsArray. This function takes the double precision matrix data and packs it into a Simulink.TsArray based on the definition of the type INPUT_BUS (including sizes and data types). The resulting TsArray is then suitable to drive a simulation of that component without the need for altering the inport in the model or creating a test harness.

This script is dependent on the functions CreateTsArray.m, CreateTsArray.p, CreateTimeSeries.m, and CreateTimeSeries.p

引用

Mike Anthony (2024). Create Bus Data for Models with Root-Level Bus Inputs (https://www.mathworks.com/matlabcentral/fileexchange/25616-create-bus-data-for-models-with-root-level-bus-inputs), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2008b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
謝辞

ヒントを与えたファイル: CreateMatrixFromModelData

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.2.0.1

Updated license

1.2.0.0

Updated 01/22/2010. Incorporates changes and bug fixes courtesy of Mark McBroom for proper functionality and additional robustness.

1.0.0.0