From and Goto block connected block list?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how to find connected Corresponding From blocks list in Goto block? (Using mscript)
Similarly for From Block?
0 commentaires
Réponse acceptée
Sameer
le 23 Août 2024
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
% Load your model
modelName = 'your_model_name';
load_system(modelName);
% Find all Goto blocks
gotoBlocks = find_system(modelName, 'BlockType', 'Goto');
% Initialize a structure to hold the result
gotoFromMapping = struct();
for i = 1:length(gotoBlocks)
% Get the tag of the Goto block
gotoTag = get_param(gotoBlocks{i}, 'GotoTag');
% Find all From blocks with the same tag
fromBlocks = find_system(modelName, 'BlockType', 'From', 'GotoTag', gotoTag);
% Store the result
gotoFromMapping.(gotoTag) = fromBlocks;
end
disp(gotoFromMapping);
Finding Corresponding “Goto” Blocks for Each “From” Block
% Find all From blocks
fromBlocks = find_system(modelName, 'BlockType', 'From');
% Initialize a structure to hold the result
fromGotoMapping = struct();
for i = 1:length(fromBlocks)
% Get the tag of the From block
fromTag = get_param(fromBlocks{i}, 'GotoTag');
% Find all Goto blocks with the same tag
gotoBlocks = find_system(modelName, 'BlockType', 'Goto', 'GotoTag', fromTag);
% Store the result
fromGotoMapping.(fromTag) = gotoBlocks;
end
disp(fromGotoMapping);
Hope this helps!
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!