MATLAB: Oop: how to switch between passing by reference and value

handlesoop

Hi all,
i've a class that inherits the "handle" class, objects therefore always passed by reference. But now I want to copy an array of objects of this class such that i can modify the original and the copy seperately. Is there any easy way to be able to decide between copying and object and passing it by reference?
Thank you!

Best Answer

Copy Method for Handle Classes
Handle classes can derive copy functionality from the matlab.mixin.Copyable class. Class designers should investigate the use of this class in their class hierarchy design