determine whether a input port is connected or not to a block

24 ビュー (過去 30 日間)
grapevine
grapevine 2012 年 2 月 24 日
コメント済み: Jorge Castillo 2024 年 9 月 17 日
Hi
I need to realize a Simulink block, which is capable to determine whether a input port is connected or not to a block if it is not connected ( which means, I guess, the input is null or empty) it returns 0 and it change the color of the port, otherwise it forwards the input to the output pourt.
I thought to use a matlab Fcn to realize this function I found helpful these commands portData = get_param(gcb,'PortConnectivity'); portData.SrcBlock
But it doesn't work as I want
Do you know if there is any way to archieve that? Any advices are welcome
thanks in advance
  1 件のコメント
grapevine
grapevine 2012 年 2 月 24 日
Sorry I said something wrong I cannot use a Matlab fcn but only an Embedded Matlab fcn, because my prof-boss doesn't wanna no mfiles in the library
If it was possible to use the Matlab fcn I would write that
if exist('u')
y = u;
else
y=1
end
but I can't
little help?

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

採用された回答

grapevine
grapevine 2012 年 3 月 12 日
I found it! I wrote this code in a callback function
portData=get_param(gcb,'PortConnectivity');
if (portData(1).SrcBlock==-1)
set_param(gcb,'Intern_External','0')
else
set_param(gcb,'Intern_External','1')
end
clear PortData
and it works

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by