MATLAB: Is there a method to make a copy of an object of a class inheriting from the handle class in MATLAB 7.6 (R2008a)

classcopyhandleMATLABmcosobjectooporiented

I would like to make a copy of an object of the MATLAB handle class – and I would like to know which method I can use to do this.

Best Answer

This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
There is no method to this in MATLAB 7.6 (R2008a). You could create a default copy method that just copies properties according to the way values are copied. This method could be put this in a base class.
However, this should be avoided as in "handle" class because handles are most often used to represent unique classes (like Simulink blocks or Handle graphic objects) where it is not possible (or allowed) for all properties of the class to have exactly the same values in 2 or more instances.