Clear Filters
Clear Filters

How to access Bus Ports parameter from action bar in Buscreator/Busselector blocks?

24 views (last 30 days)
When programmatically change bus selector/bus creator block to bus element port block through clicking by option from action bar "Bus Ports"? How can I programmatically do this in matlab?
for exampe from first image comment.png to access comment out parameter using get(gcbh,'commented');
same what parameter name to access busports ? --->from second image busports.png

Answers (1)

Rajanya
Rajanya on 25 Sep 2024 at 4:38
I understand that you want to access and control the ‘Bus ports’ parameter from action bar in a ‘Bus Creator/ Bus Selector’ programmatically.
The number of input ports can be initialized using the ‘Number of inputs’ parameter in a ‘Bus Creator’. The following lines of code can be used to set and get the input parameter of a ‘Bus Creator’ programmatically.
set_param(gcb,'Inputs','element1,element2,element3,element4')
get(gcbh,"Inputs")
The ‘set_param’ sets the input parameters and the incoming elements to the bus, thereby varying the number of input ports. The ‘get’ method called on the ‘current block handle’, indicated by ‘gcbh’, gives us the current number of input ports of the ‘Bus Creator’.
For more information about the parameters of a ‘Bus Creator block’, refer this documentation page: https://www.mathworks.com/help/releases/R2020b/simulink/slref/buscreator.html#mw_0b4c698d-d93d-4b10-8bca-8ae11894f317
Hope this helps!

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!