Programmatically to get member data type in In Bus Element Block

Hello everyone
i would like to get data type of member in the bus element
could anyone suggest me with an example code

2 件のコメント

Balaji
Balaji 2024 年 9 月 19 日
Thank you
Adarsh
Adarsh 2024 年 9 月 25 日
Ok I will teach you

サインインしてコメントする。

回答 (5 件)

Ganesh
Ganesh 2024 年 8 月 6 日
I have created and uploaded an example file with an "Out Bus Element Block" and shown how to access the "Data Type" in the following code:
open_system("example");
block = Simulink.findBlocksOfType(bdroot,'Outport');
portname = get_param(block(1),'PortName');
% Here, we have only one Outport, you might need to modify in order to specify
% which block corresponds to Out Bus Element
param = get_param([bdroot '/' portname '.Signal.signal1'],'DataType')
param = 'int64'
close_system(bdroot)
Further, you can use the following documentation which illustrates the ability to set a parameter, and use the convention to get parameters too:
Hope this helps!

7 件のコメント

tan boonmee
tan boonmee 2024 年 8 月 6 日
thank you very much for your answer @Ganesh
i understood the concept of bus element parameter extraction
but it is not works for me.
the error it shown "Invalid Simulink object name"
Ganesh
Ganesh 2024 年 8 月 6 日
編集済み: Ganesh 2024 年 8 月 6 日
Could you please share the model that you are using? Or a part of it should be good too.
tan boonmee
tan boonmee 2024 年 8 月 7 日
thank you every much
but sorry i can not share it or a part of it .
Ganesh
Ganesh 2024 年 8 月 7 日
That's okay.
The naming should go something like this -- model_name/portname.NestedData.var
Do ensure that this is being used. Also, try removing any spaces in your model name, port name or variable names.
tan boonmee
tan boonmee 2024 年 8 月 7 日
thank you very much for your suggestion
Balaji
Balaji 2024 年 9 月 19 日
Thank you
Adarsh
Adarsh 2024 年 9 月 25 日
Thanks for your confirmation

サインインしてコメントする。

Raghava S N
Raghava S N 2024 年 8 月 7 日

0 投票

Hi,
To programmatically obtain the data type attribute value of an In Bus Element, the function “get_param” should be used. The data type attribute value of an In Bus Element corresponds to the parameter ‘OutDataTypeStr’. This parameter should be passed to the “get_param” function, to programmatically obtain the data type of the bus element. For more information, refer to this documentation link of the function “get_param” - https://www.mathworks.com/help/simulink/slref/get_param.html.
get_param("<path_to_OutBus>/OutBus.NestedBus.Chirp", "OutDataTypeStr")
Note: Modify the path so that it corresponds to the correct location of OutBus” in your model.
Please refer to this documentation link for more details on programmatically accessing attributes of the In Bus Element - https://www.mathworks.com/help/simulink/slref/inbuselement.html#:~:text=elements%0Ano%20default-,Attributes,-To%20specify%20attributes
Hope this helps!
Raghava

2 件のコメント

tan boonmee
tan boonmee 2024 年 8 月 7 日
thank you very much for your answer
but i have try above method before , it is not work TT.
Adarsh
Adarsh 2024 年 9 月 25 日
Ok thank you

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulink Functions についてさらに検索

質問済み:

2024 年 8 月 6 日

回答済み:

2024 年 9 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by