I am running into an infuriating problem with Matlab, and an earlier answer to apparently the same problem didn\'t help me, unfortunately. I apologize that the question is
You have an intermediate instance myClass.father
that is not being destroyed by MATLAB. You have to delete
it yourself
>> clear grandpa
>> delete(son.precursors{1})
>> clear son
>> clear classes
>> son = myClass.son
son =
son
>> sumVal(son)
ans =
6
Edit: Alternatively, you can add a destructor to your class
function delete(obj)
if isa(obj.precursors{1}, 'myClass')
delete(obj.precursors{1});
end
end
and use delete(son)
instead of leaving it to clear
function to destroy. You can extend this to your case and recursively delete all instances in your tree.