MATLAB: How to retrieve the name of a signal coming into a Bus Creator block in Simulink, when the signal is not propagated from a Subsystem, without having to update the diagram

buscreatornamesignalhierarchysimulink

I have a model in which the name of the signal entering a Bus Creator is not available as the signal is coming from a Subsystem and the name of the signal is not propagated. The 'Show propagated signals' property cannot be changed as it is included in a subsystem inside a library.
The name of the signal is still available under 'Signals in the bus' in the Function Block Parameters dialog box of the Bus Creator. But it is not available when using the 'PropagatedSignals' property of the Inport of the bus, before the model is updated, as shown in the following code snippet:
busCreator = 'model2/Subsystem1/Bus Creator1';
lh = get_param(busCreator,'LineHandles');
srcPort = get_param(lh.Inport(1),'SrcPortHandle');
get_param(srcPort,'PropagatedSignals')
ans =
''
The code snippet returns the correct name of the signal when the model has been updated. But it is impractical to update the diagram before extracting the name of the signal due to the time taken to update the model. Thus I want to retrieve the name of the signal from the command line without having to update the model.

Best Answer

The ‘SignalHierarchy’ property of the Outport of the bus can be used to extract the name of the children signals. Though the name of the Inport signals is not available before the model is updated, if the children signals of the Outport are accessed, then the name is visible even before the model is updated.
Here is an example on how to extract the name of the signal from the command line, by using the 'SignalHierarchy' property.
busCreator = 'model2/Subsystem1/Bus Creator1';
ph = get_param(busCreator,'PortHandles');
sh = get_param(ph.Outport, 'SignalHierarchy')
sh.Children(1).SignalName