I'm trying to modify an immutable/protected property of a sub class, using a superclass method or an external utility function (I'm trying to use this function in the subclass's constructor, of course).
Example (of what I would like to do):
classdef Supmethodsfunction self = setProperties(self, varargin)% This method sets the properties of the class% the input arguments come in the form 'propname1', val1, 'propname2', val2, ......end % setPropertiesend % methodsend % classdef Supclassdef sub < Supproperties (SetAccess = immutable)prop1prop2prop3end % propertiesmethodsfunction self = sub(varargin)% constructorself = setProperties(self, varargin)end % supend % methodsend % classdef sub>> SomeObj = sub('prop1', 1, 'prop2', 10, 'prop3', 100);
This code doesn't work, I get the error message 'You cannot set the read-only property 'prop1' of sub.'
I'm OK with setting sub's properties to be protected, but I wouldn't want them to be public. I'm also OK with the idea that setProperties would be an external utility function (not defined in the superclass), but then again, I'm not able to use setProperties in the constructor of sub.
Would appreciate your help on that.