Unable to extract simulink block paths in my model
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Suresh
el 8 de Nov. de 2022
Comentada: Suresh
el 10 de Nov. de 2022
Hi all,
I have one model, in that i would like to extract yellow colour background simulink block paths (only need path) only in all levels,
but i unable to do that, can u pls help me.
here is my code
[model_name, path] = uigetfile('*.slx','Select the model file')
modelname = model_name(1:end-4)
load_system(model_name)
dpath = find_system;
%Model_Subsystem = find_system('SearchDepth',3,'regexp','on','BackgroundColor','Yellow')
Model_Subsystem = find_system(modelname,'BlockType','Subsystem')
subsys_colour = get_param(Model_Subsystem,'BackgroundColor')
for i = 1:length(subsys_colour)
if strcmp(subsys_colour{i},'Yellow')
new_path = subsys_colour{i}
end
end
0 comentarios
Respuesta aceptada
Nishan Nekoo
el 10 de Nov. de 2022
Editada: Nishan Nekoo
el 10 de Nov. de 2022
On line 6, it should be 'SubSystem' instead of 'Subsystem'. Instead of using 'strcmp', consider using 'strcmpi' to prevent the case from being an issue. Furthermore, instead of using a for loop, you can leverage indexing as follows:
[model_name, path] = uigetfile('*.slx','Select the model file')
modelname = model_name(1:end-4)
load_system(model_name)
dpath = find_system;
%Model_Subsystem = find_system('SearchDepth',3,'regexp','on','BackgroundColor','Yellow')
Model_Subsystem = find_system(modelname,'BlockType','SubSystem')
subsys_colour = get_param(Model_Subsystem,'BackgroundColor')
paths = Model_Subsystem(strcmpi(subsys_colour,'Yellow'))
Be sure to check out this MATLAB answers post too:
https://www.mathworks.com/matlabcentral/answers/102253-how-can-i-find-all-subsystems-my-model-contains-in-simulink-7-8-r2011b
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!