MATLAB: How to change a common property of multiple blocks selected with a mouse in a Simulink model

accessmanyselectionseveralsimulink

I have a model and I have selected multiple blocks with a mouse. I want to change the background color of all these blocks. How do I do this? GCB function returns only the handle to one block.

Best Answer

The 'Selected' property of a block provides information on the status of whether or not the block is selected. The following code can be used to change the background color of the selected blocks:
% Select blocks in a model
a = find_system(gcs,'Selected','on');
% Change the background color of each selected block
for i = 1 : length(a)
set_param(a{i},'BackgroundColor','red')
end