how to delete unconnected terminators using M-script

8 visualizaciones (últimos 30 días)
dhiraj ambadkar
dhiraj ambadkar el 29 de Abr. de 2021
Respondida: Sameer el 12 de Mzo. de 2025
i am trying to delete unconnected terminators using M script
I know delete_block() can be use but not able get proper argument for this operation
i am using command
FindAllTerminator = find_system(modelName, 'Unconnected', 'on', 'BlockType', 'Terminator');

Respuestas (1)

Sameer
Sameer el 12 de Mzo. de 2025
To delete unconnected terminator blocks in a Simulink model using M-script, you can use the "find_system" function to locate all unconnected terminator blocks and then use the "delete_block" function to remove them.
Here's how you can do it:
% Define the model name
modelName = 'your_model_name';
% Load the model
load_system(modelName);
% Find all unconnected terminator blocks
FindAllTerminator = find_system(modelName, 'BlockType', 'Terminator', 'LineHandles', 'on');
% Loop through each terminator block and check if it is unconnected
for i = 1:length(FindAllTerminator)
% Get the line handles of the block
lineHandles = get_param(FindAllTerminator{i}, 'LineHandles');
% Check if the input port is unconnected
if lineHandles.Inport == -1
% Delete the unconnected terminator block
delete_block(FindAllTerminator{i});
end
end
% Save and close the model
save_system(modelName);
close_system(modelName);
Hope this helps!

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by