How I can find the connection between two blocks of simulink from matlab?

36 ビュー (過去 30 日間)
claudia
claudia 2013 年 12 月 15 日
Hi everybody, I have a problem and I have not found a solution until now. I have, for example, two blocks on simulink, a block "From" connected to an block "Goto", but in this case I don't know it but the only things I know is that there is the block "From" in that simulink. How can I find, from matlab, the connection between these two block? There is a command from matlab that return this information? I tried with "get_param" but doesn't work! Thank you
  4 件のコメント
Hayatullahi Adeyemo
Hayatullahi Adeyemo 2021 年 3 月 9 日
Please, what if I have two [known] Simulink blocks and I want to know if they are both connected, how do I go about identifying if connectivity exists between them?
Hayatullahi Adeyemo
Hayatullahi Adeyemo 2021 年 3 月 22 日
Anyone to help me pls?

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 16 日
編集済み: Azzi Abdelmalek 2013 年 12 月 16 日
To get the blocks that are connected to your block block1
b=get_param('your_model/block1','PortConnectivity')
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 16 日
編集済み: Azzi Abdelmalek 2013 年 12 月 16 日
b=get_param('your_model/block1','PortConnectivity');
n=numel(b) % number of blocks connected to block1;
%Check if each block from the n blocks is a source block or a destination block
for k=1:n
s=get(b(k).SrcBlock);
f='Source';
if isempty(s)
s=get(b(k).DstBlock);
f='Destinataion';
end
out{k,1}=f;
out{k,2}=s.BlockType;
out{k,3}=s.Name
end
disp(out) % the first column indicate if a block is a source or a destination, the second indicate the type, and the third is the name.
claudia
claudia 2013 年 12 月 16 日
Thank you! You've been really kind!

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

その他の回答 (1 件)

Shishir Dwivedi
Shishir Dwivedi 2021 年 2 月 11 日
Can you please check the Finding Model utility on File Exchange, this APP will allow you to create custom dataset for your models, wherein you can get the block conectivity patterns as well.
Best Regards,
Shishir.

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by