Get names of current Simulink block input signal

20 ビュー (過去 30 日間)
Joris
Joris 2011 年 8 月 1 日
If i use gcb, i get the name of the currently selected simulink block. What I also need is the names of the block inputs and outputs. Is there anyway to retrieve these?
The block that I am checking is not yet connected to any other blocks. So its a subsystem, and in the subsystem the ports are defined. But the subsystem is the only block in the simulink .mdl. I'm now trying with find_systems, but cant yet get the right answer.
I want to automatically check whether all inputs that are supposed to be there are in fact there.

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 1 日
h_Inports=find_system(SubsystemBlock,'FindAll','On','SearchDepth',1,'BlockType','Inport');
Name_Inports=get(h_Inports,'Name');
  2 件のコメント
Joris
Joris 2011 年 8 月 1 日
Thanks!
I modified it a bit to:
find_system(gcs,'SearchDepth',2,'BlockType','Inport');
and that did it!
Fangjun Jiang
Fangjun Jiang 2011 年 8 月 1 日
Glad that is what you were looking for. The issue with your question is that you were looking for the block names of the Inport and Outport blocks in your subsystem. They are not signal names. Screeram's answer is right for the signal names and of course, your subsystem needs to be connected to make that work.

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

その他の回答 (1 件)

Sreeram Mohan
Sreeram Mohan 2011 年 8 月 1 日
Hi Joris,
You could try
a = get_param9gcb, 'portconnectivity') this should return the handles for the srcblocks and destination blocks !
--sreeram
  1 件のコメント
Joris
Joris 2011 年 8 月 1 日
Thanks for the quick reply!
It's in the right direction but Im not quite there. a.SrcPort now returns a array of size 56 with empty names. The block that I am checking is not yet connected. So its a subsystem, and in the subsystem the ports (indeed 56) are defined. But the subsystem is the only block in the simulink .mdl.
I'm now trying with find_systems, but cant yet get the right answer.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by