get(gcbh) %Alle verfügbaren Parameter des aktuell makierten Blocks abrufen set_param(foundBlocks(i),'GotoTag',paramValue) %Parameter ändern
Als beispiel werden hier alle Goto und From Blöcke gesucht und an die jeweiligen Tags „_2“ angehangen. Die Änderung wird nur durchgeführt, wenn der bisherige Tag noch nicht auf die gewünschte Endung endet.
pfad = 'mysimulinkmodel/layer1';
set_ending = '_2';
countChangesGotos = 0;
foundBlocks = find_system(pfad, 'FindAll', 'on', 'BlockType','Goto');
foundBlocks_From = find_system(pfad, 'FindAll', 'on', 'BlockType','From');
foundBlocks = [foundBlocks ; foundBlocks_From];
for i = 1:length(foundBlocks)
paramValue = get_param(foundBlocks(i),'GotoTag');
if strcmp( paramValue(end-length(set_ending)+1:end), set_ending) == 0
paramValue = [paramValue set_ending];
set_param(foundBlocks(i),'GotoTag',paramValue)
countChangesGotos = countChangesGotos + 1;
end
end
disp(['Gotos und Froms geändert: ' num2str(countChangesGotos)]);
[:]