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

24 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by