Code covered by the BSD License  

Highlights from
copymyobj

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 1.36 KB File ID: #20972

copymyobj

by Holger Hiebel

 

05 Aug 2008 (Updated 05 Aug 2008)

Workaround to create copies of objects inheriting from the Matlab 'handle'-class

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Matlab Pre-Release PR2008b or higher
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
copy Holger Hiebel 22 Oct 2008 10:13:14
custom Holger Hiebel 22 Oct 2008 10:13:14
matlab objects Holger Hiebel 22 Oct 2008 10:13:14
handle class Holger Hiebel 22 Oct 2008 10:13:14
utilities Holger Hiebel 22 Oct 2008 10:13:14
inherit Holger Hiebel 22 Oct 2008 10:13:14
clone per isakson 03 Jul 2010 14:04:52
deep copy per isakson 03 Jul 2010 14:04:52

Contact us at files@mathworks.com