MATLAB: Get signal name at inport of subsystem

callbackfind_systemsimulink

Hi,
I would like a subsystem to know the name of its input so that it can be used for a custom logging solution. I expect a callback on the subsystem which defines a variable could be one way to realize it. I just can't figure out how the callback should obtain the name.
Here is an illustration from the top level:
Capture.PNG
And how I would get the value from the callback.
in_subsys.PNG
Do you have any ideas how the callback would look?

Best Answer

The first case truely has the signal name. You can get it like below. In second case, you need to get the name of the Constant.
ph=get_param(SysBlockPath,'PortHandles');
sp=ph.Inport(1);
SignalName=get(sp,'Name');