Using Bus in Simulink

1 view (last 30 days)
gili Maimon
gili Maimon on 26 Mar 2023
Answered: Sara Nadeau on 27 Mar 2023
The only thing I want to do is to load into Simulink a timetable or a struct that one of is filed is time, and the rest of the field are the signals.
I want each field to be a signal in Simulink according to the "time" field. The documantation is not clear at all, and I didnt find how to do this simple task.
In summery: I want to load a single timetable or a struct (not to create for each column/field a time serious) with From WorkSpace block, and to connect this block to bus selector in order to see thos signals.
It sound to me like a simple task but I didnt mange to find a document that show how to do it without create to each column/ filed a seprate time serious array.

Answers (2)

Paul
Paul on 26 Mar 2023
Does Load Data using the From Workspace Block include an example that will help?

Sara Nadeau
Sara Nadeau on 27 Mar 2023
When you load external input data for a bus using most loading blocks, the bus produced in the model is nonvirtual. That means that the bus is not simply a group of signals but also a definition of the interface, including hierarchy, names, data types, and any other bus element attributes you define.
In order to load input data for a bus using the From Workspace block, you need to create a Simulink.Bus object that defines the data type for the loading block.
Each element in the bus is an independent element, so you do create the data for each element independently. Then, you create a structure in which the bus elements are arranged with the same hierarchy as the bus object definition, using the names of elements in the bus object as the names for the fields in the structure.
The Load Bus Data section of the doc page linked in the other answer shows an example of how to do this.
Loading input data for a bus can be a bit simpler when you use In Bus Element blocks instead of the From Workspace block. You can load data for a virtual bus, so you do not need to create the Simulink.Bus object. You do still need to create data for each element in the bus independently. Here's an example: Load Input Data for a Bus Using In Bus Element Blocks.

Categories

Find more on Composite Interfaces in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!