function hsvObj = HSVColor(obj)
if isa(obj,'RGBColor')
hsvObj = HSVColor(rgb2hsv(obj.Color));
end
end
end
endCreate an array of RGBColor and HSVColor objects with the revised superclass:crgb = RGBColor([1 0 0]);
chsv = HSVColor([0 1 1]);
ary = [crgb,chsv];
class(ary)ans =RGBColorMATLAB calls the converter method for the HSVColor object, which it inherits from the
superclass. The second array element is now an RGBColor object with an RGB color
specification assigned to the Color property:ary(2)ans =RGBColor with properties:Color: [1 0 0]ary(2).Colorans =1 0 0If the leftmost object is of class HSVColor, the array ary is also of class HSVColor, and
MATLAB converts the Color property data to HSV color specification.ary = [chsv crgb]ary =1x2 HSVColor10 Object Arrays