copymyobj

Workaround to create copies of objects inheriting from the Matlab 'handle'-class
821 Downloads
Updated 5 Aug 2008

View License

Some specific things available in Matlab object-oriented programming can only be done with custom Matlab classes when you inherit from the Matlab built-in handle class. This includes for example adding dynamic properties, listeners etc.

There is no default method to create a copy of an object of such a 'handle-class'. Using the simple assignment (e.g. y=x) in that case only copies the handle (=the pointer) to the object.

This simple workaround uses the built-in save function to create a new object which is a copy of the original object.

The provided function does at the moment only work with Matlab Pre-Release PR2008b which solves a previous bug in the built-in 'save' function.

Cite As

Holger Hiebel (2024). copymyobj (https://www.mathworks.com/matlabcentral/fileexchange/20972-copymyobj), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Software Development Tools in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0