MATLAB: How to populate the signal names to match the bus object signal names in the Bus Creator block in Simulink 6.6 (R2007a)

buscreatorbusobjectsimulink

I want all the signals entering a Bus Creator block to respect the names specified in a bus object. I would like all the names to be automatically assigned to the signals/buses coming into the Bus Creator based on the Bus Object specified.

Best Answer

The ability to assign signal names automatically from the specified Bus Object is not available in Simulink 6.6 (R2007a).
It is possible to create a script that automatically assigns the names specified in the Bus Object Elements to the signals connected to the bus object. For an example, download the attached files MainBus.mat, BusToBeNamed.mdl and DefineInputs.m. The Simulink model contains a Bus Creator block assiciated with a Bus Object. The following example MATLAB code can be used to assign the appropriate names to the signals connected to the bus.
load MainBus
open_system('BusToBeNamed');
S = Simulink.Bus.objectToCell({'MainBus'});
blk = 'BusToBeNamed/Bus Creator';
ph = get_param(blk,'PortHandles');
lh = get_param(ph.Inport,'Line');
N = length(S{1}{4});
for i = 1:N
set(lh{i},'Name',S{1}{4}{i}{1});
end