MATLAB: Is it possible to temporarily disable the private attribute of object properties in debug mode in MATLAB 7.9 (R2009b)

accessclassesdispdisplayMATLABmetaoopprivatepropsprotectedpublic

When I'm stepping through my code, it would be nice to be able to "peek" into the contents of private properties in my objects from scopes where this would not normally be possible during regular program execution. Is there a way to do this without having to set all of my properties to public temporarily and then setting them back to private when I'm done debugging?
For example, if I create the class definition:
classdef test
properties(SetAccess= private, GetAccess=private)
a = 'a';
b='b';
end
properties
c='c';
d='d';
end
end
and instantiate this object in another function, 'call_test.m':
function call_test
t = test;
end
I would like to be able to see the private properties of this object when running 'call_test.m' in debug mode.

Best Answer

The ability to temporarily disable the private attribute of object properties does not currently exist in MATLAB 7.9 (R2009b). You can access the private properties of objects while debugging using either of the following methods:
1. Temporarily set the GetAccess attribute of the properties to public
2. Create a public method to display the contents of the private properties, as in the following class definition. This method can use Meta-Classes to analyze the class definition and determine all property names.
classdef test
properties(SetAccess= private, GetAccess=private)
a = 'a';
b='b';
end
properties
c='c';
d='d';
end
methods
function mydisp(obj)
% To display the private data
m = metaclass(obj);
metaProps = m.Properties;
nProps = numel(metaProps);
disp('Properties:')
for n=1:nProps
fprintf(' %s: %d (SetAccess = %s; Get Access = %s)\n',...
metaProps{n}.Name,metaProps{n}.DefaultValue,...
metaProps{n}.SetAccess, metaProps{n}.GetAccess)
end
end
end
end