Get data type of Simulink blocks programmatically

50 ビュー (過去 30 日間)
giga
giga 2016 年 2 月 8 日
コメント済み: giga 2016 年 2 月 10 日
I'm interested in getting data type of all input and output ports of some built-in block. I can view this information when I type showblockdatatypetable in the Matlab command window. However, is there a way to get this information programmatically (perhaps calling get_param or some other function)?
I read that I can get some (or all?) of these information after compiling a model and calling get_param for CompiledPortDataTypes parameter. However, I am interested in getting these information without compiling the model if possible, as (I guess) this page puts some restrictions on what type of models can be compiled using the command.
I'm very new to Simulink and I'll appreciate answers to some related questions:
  1. If I change how blocks are connected (e.g. replace a block), do I need to compile the model again before calling get_param for 'CompiledPortDataTypes' parameter?
  2. Do we always need to compile a model to learn it's blocks' ports' data types or can we use the information obtained from the Simulink documentation ( showblockdatatypetable shows these information).

回答 (1 件)

Siva Prasad
Siva Prasad 2016 年 2 月 10 日
To get particular port data type,first highlight that block then you can use "get_param(gcbh,'OutDataTypeStr')". For this no need to compile model but that model must be loaded.
  1 件のコメント
giga
giga 2016 年 2 月 10 日
Thanks! OutDataTypeStr is not available for all blocks, i.e. it's not a common block parameter. Also, what does this parameter actually mean? It also looks like we can set the parameter using set_param? And what about blocks which have more than one output ports... will this parameter affect all of the block's ports?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by