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

6 views (last 30 days)
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 Comment
grapevine
grapevine on 24 Feb 2012
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?

Sign in to comment.

Accepted Answer

grapevine
grapevine on 12 Mar 2012
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!