for a handle class contains another handle object. I would do deep copy "recursively". (the following one might face the loop situation.)
classdef B < handle
properties
a % A obj
end
methods
function this = B()
this.a = A();
end
% class A should have the SIMILAR
% clonePublic function
function newObj = clonePublic(this)
props = properties(this);
newObj = B();
for i = 1: length(props)
tmp = this.(props{i});
if(isa(tmp,'handle'))
newObj.(props{i}) = tmp.clonePublic();
else
newObj.(props{i}) = tmp ;
end
end
end
end
end