1
votes

I have five areas into a plot in matlab and I would want to change the colors of all of them but I cannot find any code that help me.

In matlab tutorial, I found this:

h(1).FaceColor=[0 0.25 0.25];
h(2).FaceColor=[0 0.5 0.5];
h(3).FaceColor=[0 0.75 0.75];

But, I've got this error in matlab: "Structure assignment to non-structure object".

Could anyone help me to figure this out ?

1

1 Answers

1
votes

You are likely running a Matlab version older than R2014, in which dot assignment were introduced for graphics object (Check here). Therefore you need to use the good old way of changing elements properties:

set(h(1),'FaceColor',[0 0.25 0.25]);
set(h(2),'FaceColor',[0 0.5 0.5]);
set(h(3),'FaceColor',[0 0.75 0.75]);