Programmatically comment blocks residing in a subsystem
Mostra commenti meno recenti
Hi,
I am trying to programmatically comment some subsystem blocks in my model. Here I have shown a simplified version of in the attached model file. ( actual number of subsystem block is in 100s)
Subsytem1 has: E7kW_Medium Range1, E7kW_Long Range1
Subsytem2 has: E7kW_Medium Range2 , E7kW_Long Range2
clc
clear all
open_system('Commenting_Programmatic')
Num_7L=2
Num_7M= 2
Status_7L= 'on'; % Comment status
Status_7M= 'on';
for kk= 1: Num_7L
set_param([gcb,'/E7kW_Long Range',num2str(kk),''],'Commented',Status_7L)
end
for ll= 1: Num_7M
set_param([gcb,'/E7kW_Medium Range',num2str(ll),''],'Commented',Status_7M)
end
E7kW_Medium Range1 gets commented out, but E7kW_ Medium Range2 ( residing in Subsystem2) gives error , as the gcb still reads the previous location w.rt Subsystem1.
If I put the EV subsystem in model root, then commenting works fine. But how can I get address of the block when it is residing in separate subsystems?
Thanks,
Haroon
Risposta accettata
Più risposte (1)
Fangjun Jiang
il 20 Nov 2023
0 voti
If doing it programmingly, never use "gcb" or "gcs". Instead, use the full block path like "RootModelName/SubSystemName/BlockName". If the "SubSystemName" is varying, then use find_system() to find the SubSystem block and get its name.
1 Commento
Haroon Zafar
il 24 Nov 2023
Categorie
Scopri di più su Programmatic Model Editing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!