MATLAB: New class object every iteration

classMATLABobjectoop

Hello. I'm trying to create new class object in every single iteration. I've founded a lot of topics how to do this with matrixes, cell arrays and many other elements, but not with object class. The idea is to creeate something like this
for i = 1:1:10
new_obj_{i}=class_name
end
after end of the for cycle, there should be 10 objects of class_name, named: new_obj_1, new_obj_2, new_obj_3 and so on..
Is there any way how to do it?

Best Answer

In most cases it's better to create an array of objects. The documentations provides one way. See Construct Object Arrays. What are the pro and cons in your case?