Clear Filters
Clear Filters

How to update a line name with constant block name

7 views (last 30 days)
Hi
Is there any method in simulink to update the line name with the existing block name, Attached the image where i need to see the block names A,B, D in the lines connecting to the bus creater, Without manually changing in the line is there any option to do the name change for all lines connecting to bus creater block simultaneously

Answers (1)

Ayush Aniket
Ayush Aniket on 8 May 2024
Edited: Ayush Aniket on 8 May 2024
Hi Vignesh,
There is no functionality in Simulink to change the name of all the lines connected to the Bus Creator to its originated block name. however, you can perform this task using a MATLAB script as shown below:
% Specify the name of your model and the Bus Creator block path
modelName = 'myModel';
busCreatorPath = 'myModel/Bus Creator';
% Load the model (if it's not already open)
load_system(modelName);
% Get handle to the Bus Creator block
busCreatorHandle = get_param(busCreatorPath, 'Handle');
% Get all lines connected to the input ports of the Bus Creator
lines = get_param(busCreatorHandle, 'LineHandles');
inputLines = lines.Inport;
% Iterate through each input line
for i = 1:length(inputLines)
if inputLines(i) ~= -1 % Check if the line is valid
% Get the block connected to the other end of the line
srcBlockHandle = get_param(inputLines(i), 'SrcBlockHandle');
srcBlockName = get_param(srcBlockHandle, 'Name');
% Update the line name
set_param(inputLines(i), 'Name', srcBlockName);
end
end
The code uses MATLAB's 'set_param' and 'get_param' functions to get and set the Simulink parameter values. Refer to the documentation below to read more about all of the Simulink 'parameter' you can modify using these functions:
Hope it helps.

Categories

Find more on RF Blockset Models for Transceivers in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!