Assign Port name "Data Type" from Command Window

8 ビュー (過去 30 日間)
Cory Dinkle
Cory Dinkle 2022 年 2 月 14 日
編集済み: Fangjun Jiang 2022 年 4 月 28 日
Hello, I am hoping to get some help with writing a script to expedite some manual bus port setting changes I have to make occasionally in Simulink. Is it possible to change a Bus's Data Type from the Command Window? If so, where would I find this command (or better yet, what is the command I would use)?
I've attached a screenshot to show what I mean. Thanks in advance!

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 2 月 15 日
編集済み: Fangjun Jiang 2022 年 2 月 15 日
Try it on one block, get and set the data type
get_param('ModelName/InportName','OutDataTypeStr')
set_param('ModelName/InportName','OutDataTypeStr', 'Bus: xxxx')
  10 件のコメント
Cory Dinkle
Cory Dinkle 2022 年 4 月 27 日
Could you please explain why it would be a bad modeling practice? Our system has many busses, all of which are routed as From/GoTo's at a particular level of the model.
Fangjun Jiang
Fangjun Jiang 2022 年 4 月 28 日
編集済み: Fangjun Jiang 2022 年 4 月 28 日
Using Goto/From block should be no reason/jusitificaiton for doing this. In principle, a signal or bus should be defined only once, preferably at its true source (e.g. a Bus Creator block). All other places like Ports they should be inherited. Once the model is updated, you will see the propagated bus name/definition. Inport block at the root level is regarded as source.
Defining the same bus in multiple places could cause inefficiency in code generation, even when the definition is consistent. When you need to make a change, you have to make the same change in multiple places. When the definition is not consistent, you got errors.

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

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by