MATLAB: How to find the names of private dynamic properties in MATLAB 7.8 (R2009a)

MATLAB

I have an object of a class which is derived from dynamicprops; some of the dynamic properties which are added to the object are set to private (GetAccess=SetAccess=private). I can use FINDPROP to get more information about these properties. However for FINDPROP I need to know the names of the properties; I noticed that the names of:
– Public normal properties can be retrieved using PROPERTIES and METACLASS
– Private normal properties can be retrieved using METACLASS
– Public dynamic properties can be retrieved using PROPERTIES
But I do not know how to find the names of Private Dynamic Properties.

Best Answer

The ability to retrieve the names of Private Dynamic properties is not available in MATLAB R2009a.
As the name suggests, dynamic properties are dynamically added so that means that at some point in time (when you actually add the property) the name should be known. Please make sure you do not lose track of the name at that point. A way to ensure this could be to write you own superclass which keeps track of the property names and derive your class from this class instead of from dynamicprops; an example of such a super class is given below:
classdef mydynamicprops < dynamicprops
properties (Access=private)
% In this private property we save the names of the dynamically
% added properties
dynpropnames
end
methods
function y=addprop(obj,pname)
% First add the property to the list of dynamic properties
obj.dynpropnames{end+1} = pname;
% Then call the addprop method of dynamicprops, which actually adds the dynamic property
y=addprop@dynamicprops(obj,pname);
end
function y=GetDynamicProperties(obj)
% Return a list of dynamic properties
y=obj.dynpropnames;
end
end
end