I have a class MyData and a class Container
classdef MyData < handle
properties
x
end
methods
function obj=MyData()
obj.x=0;
end
end
end
classdef Container < handle
properties
myobject_array
end
methods
function obj=Container(n)
obj.myobject_array(n)=MyData();
end
end
end
When I want to construct a Container object by Container(3), the following error is thrown
The following error occurred converting from MyData to double:
Conversion to double from MyData is not possible.
Error in Container (line 8)
obj.myobject_array(n)=MyData();
How can I write the constructor of Container to make a array of MyData object be constructed in Container object?