How to get a Bus Type Object From a Bus Name

6 ビュー (過去 30 日間)
Dominic
Dominic 2025 年 3 月 26 日
回答済み: Pratyush Swain 2025 年 3 月 27 日
Say I have a nonvirtual bus named FooBus defined in the Simulink type editor. How would I get FooBus's Bus Object (so I can access its element definitions), given only its name as a string (ie "Bus: FooBus")?
Put another way, I'm looking to get the following object having only the name of the bus.
Bus with properties:
Description: ''
DataScope: 'Auto'
HeaderFile: ''
Alignment: -1
PreserveElementDimensions: 0
Elements: [4×1 Simulink.BusElement]

回答 (1 件)

Pratyush Swain
Pratyush Swain 2025 年 3 月 27 日
Hi Dominic,
You can use the 'evalin' function for this purpose. Assuming you have defined your bus object in the base workspace with the name 'FooBus', you can access the object through its name in the following manner:
bus_name = 'FooBus';
bus_obj = evalin('base',bus_name)
For more information on the use of this function, you can refer to: https://www.mathworks.com/help/matlab/ref/evalin.html
Hope this helps.

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by