How to programmatically distinguish between different block type?

5 ビュー (過去 30 日間)
Sohil Shrestha
Sohil Shrestha 2021 年 12 月 28 日
編集済み: Paul 2021 年 12 月 28 日
We can get the block type using
get_param(gcb,"BlockType")
However, several block types are returned as Subsystem or S-function for which we can look at ReferenceBlock parameter
get_param(gcb,"ReferenceBlock")
But the Delay block has different version such as Variable Integer Delay, Enabled Delay etc most of which returns Delay as the block type.
How do I distinguish between them?

採用された回答

Sohil Shrestha
Sohil Shrestha 2021 年 12 月 28 日
Apart of Tapped Delay In Discrete library, all other versions of Delay can be obtained by changing certain dialog box parameter.
The port information can be viewed from "InputPortMap" parameter. Given the parameter is read-only, I am assuming the order of the port label will be fixed and correspond to
get_param(< Block>,"PortConnectivity")(X).type number where X is the particular number of port.
  1 件のコメント
Paul
Paul 2021 年 12 月 28 日
Is there documentation on 'InputPortMap'?

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

その他の回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 12 月 28 日
Use instead this fcn command:
BlockPaths = find_system('MY_model','Type','Block') % MY_model.slx is Simulink model that contains model blocks including a different delay blocks
  1 件のコメント
Sohil Shrestha
Sohil Shrestha 2021 年 12 月 28 日
The above will return the full path of the block with its name.
Example . Support there is a Constant Block named 'a' in MY_model, it will return
{'My_model/a' }

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


Paul
Paul 2021 年 12 月 28 日
編集済み: Paul 2021 年 12 月 28 日
Well, it does appear that there are several blocks in the Discrete library that all have BlockType == 'Delay'
As far as I can tell, and I might be wrong, the only way to distinguish how each is configured is to interrogate other parameters of the block, like
get_param(gcb,'ShowEnablePort')
to determine which input ports are "active" (I can't think of a better word) and go from there.
The PortHandles property might also be of interest.

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by