SIMULINK testing a model that has bus input and output ports
33 views (last 30 days)
Show older comments
I have a SIMULINK model that uses bus inputs and outputs as top level ports. When I am testing it, I don't know how to create a test signal as a bus and feed it into the model. I know that the straightforward way to do it is to create lots of individual signal and use bus creator block to group those as a bus that will feed into the model. However, this may not be a very efficient way to do things. Does anyone know any alternative?
I tried to look into Mathworks website but nothing really came up. Any help would be appreciated
2 Comments
Answers (2)
Mark McBroom
on 31 May 2024
If you already have a Simulink.Bus defined, another approach is to place a constant block in the Simulink model, set its value to zero, and set the data type to be the Simulink Bus. You can connect the output of the constant block to a Bus Assignment block to override any signals that you want to have non-zero values.
The createMATLABStruct function can also be useful if you have a Simulink.Bus. This function creates a MATLAB structure with the same layout as the Bus. You can then populate individual fields with the desired value, and then use this MATLAB struct in a Simulink Constant block to generate a bus signal. Create MATLAB structures that use the same hierarchy and attributes as buses - MATLAB Simulink.Bus.createMATLABStruct (mathworks.com)
Thanks.
Mark.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!