Hi Ravi
From my understanding, you want to find the corresponding connected blocks between “From” and “Goto” blocks in a Simulink model using a MATLAB script.
We can achieve this by leveraging the “Simulink API”. For “Goto” blocks, we identify all “From” blocks that share the same tag by searching the model using the “GotoTag” parameter. Similarly, for “From” blocks, we locate all “Goto” blocks with matching tags.
Here's how you can do it:
Finding Corresponding “From” Blocks for Each “Goto” Block
modelName = 'your_model_name';
gotoBlocks = find_system(modelName, 'BlockType', 'Goto');
gotoFromMapping = struct();
for i = 1:length(gotoBlocks)
gotoTag = get_param(gotoBlocks{i}, 'GotoTag');
fromBlocks = find_system(modelName, 'BlockType', 'From', 'GotoTag', gotoTag);
gotoFromMapping.(gotoTag) = fromBlocks;
Finding Corresponding “Goto” Blocks for Each “From” Block
fromBlocks = find_system(modelName, 'BlockType', 'From');
fromGotoMapping = struct();
for i = 1:length(fromBlocks)
fromTag = get_param(fromBlocks{i}, 'GotoTag');
gotoBlocks = find_system(modelName, 'BlockType', 'Goto', 'GotoTag', fromTag);
fromGotoMapping.(fromTag) = gotoBlocks;
Hope this helps!