how to delete unconnected terminators using M-script
8 views (last 30 days)
Show older comments
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');
0 Comments
Answers (1)
Sameer
on 12 Mar 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!
0 Comments
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!