I managed to solve the problem. The code works fine. The issue was the block in the new library was linking to the old library. To stop the new library block referencing the old library block, I disabled the link on the new library block and then broke it.
How can I change the reference of blocks that use a library from one to another programmatically?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Eugene Ofori
le 13 Mai 2021
Modifié(e) : Eugene Ofori
le 15 Juil 2021
I moved a library block from one library to another and I want the blocks in my model to reference the new library before I delete the old one. I have tried to iteratively change the parameter of 'ReferenceBlock', however, when I run the code below the reference doesn't change and still reads as OldLib and when I check with Go To Library Block.
My old library was in another project, referenced by my main project and the new library is located in my main project. Does anyone know what's wrong?
model = 'System';
oldlink = 'OldLib/Filter';
newlink = 'NewLib/Filter';
load_system(model);
blocks = find_system('System', 'ReferenceBlock', oldlink);
for blockIdx = 1:size(blocks, 1)
set_param(blocks{blockIdx}), 'ReferenceBlock', newlink)
disp(get_param(blocks{blockIdx}, 'ReferenceBlock'))
end
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!