MATLAB: I cannot modify the ‘FaceAlpha’ property of the ‘Rectangle’ object

facealphaMATLABrectangle

When I create a rectangle using:
>> a=annotation('rectangle')
I can modify its 'FaceAlpha' property. However, when I create it using:
>> b=rectangle();
then there is no 'FaceAlpha' value for me to modify even though both "a" and "b" are shown as 'Rectangle' objects.

Best Answer

While both "a" and "b" are shown as 'Rectangle' objects in the Workspace, they actually come from two different classes, and therefore have different properties:
>> a = annotation('rectangle');
>> b = rectangle;
>> class(a)
ans =
'matlab.graphics.shape.Rectangle'
>> class(b)
ans =
'matlab.graphics.primitive.Rectangle'