I have this code:
allObjects=[]
for i=1:100
allObjects(end+1) = MyObject(); % push the object to the end of my vector
end
But this prints:
Conversion to double from MyObject is not possible.
Same thing if i declare allObjects as a cell array
allObjects = {}
How can I have a vector of objects in Matlab, consider I can’t know how many objects I will need to store?
allObjects = MyObject.emptywill give you an empty array of objects of classMyObject.emptyis a Public Static method of all non-abstract classes designed for this purpose. Typedoc emptyfor more information.