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

조회 수: 5 (최근 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 CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by