How can I set properties (e.g. backgroundcolor) of a Simulink Area programmatically?

44 views (last 30 days)
Hi,
I've been trying to change the background color of a Simulink Area programmatically but without effect. I can use get/set to change the value of the property backgroundcolor, but this has no influence on the displayed color. On the other hand, if I change the color manually via the context menu, the value returned for backgroundcolor will change accordingly, so it does appear to be the correct property to look at.
Thanks! Ruben
  1 Comment
Torsten Knodt
Torsten Knodt on 10 Oct 2016
What exactly do you mean by "Simulink Area"? I have checked for a block and can modify the background color, e.g. with
set_param(gcb,'BackgroundColor','red')

Sign in to comment.

Accepted Answer

Monika Jaskolka
Monika Jaskolka on 7 Dec 2017
The available properties for Simulink Areas are described here: https://www.mathworks.com/help/simulink/slref/simulink.annotation.html
To change the background color property of a Simulink Area that is currently selected, do the following:
handle = find_system(gcs, 'FindAll', 'on', 'type', 'annotation', 'AnnotationType', 'area_annotation', 'selected', 'on')
set_param(handle, 'BackgroundColor', 'green')
This works for me on 2017b.
  1 Comment
Ruben B.
Ruben B. on 8 Dec 2017
Thanks for the answer. I'm using 2015b. When I follow your steps, the appearance of the area does not change. So even though the property has obviously changed, it is not reflected in the rendering of the area element.
I retried in 2017b and there it works as expected. It seems to be a limitation/bug of 2015b then. Unfortunately we are bound to 2015b by our development process.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!