I'm trying to create some handle classes that are nested together in a struct - something like this:
classdef A < handle
properties
parent
data
end
methods
function obj = Data(parent,raw_data)
obj.parent = parent;
obj.raw_data = raw_data;
end
end
methods (Abstract)
out = get(obj)
end
end
Instances of A are compiled in another handle class:
classdef B < handle
properties
data = struct;
epoch = [0 inf];
end
methods
function load_C(obj,field_name,varargin)
obj.data.(field_name) = C(obj,varargin{:});
end
function out = get(obj,field_name)
out = obj.data.(field_name).get();
end
end
end
When I try to save such objects, the struct data looses all of its fields! This is particularly wierd to me because in other classes I've made where the handle objects are not stored in a struct and are just properties of the class, they are saved.