MATLAB Answers


Why am I unable to access application data for graphics objects created by using the copyobj function in MATLAB R2014b?

I have an axes which contains a surface plot. I assign application data to the axes object using the following command:
I then copy the axes to another figure using the 'copyobj' function in the following way:
f = figure;
new_axes = copyobj(axesHandle,f);
In MATLAB R2014a, I the new axes in the new figure has the sample application data as the original axes, however in MATLAB R2014b the new axes does not have the same application data compared to the original axes. Why is that so?




1 Answer

Answer by MathWorks Support Team on 27 Aug 2014
 Accepted Answer

Starting in R2014b, 'copyobj' does not copy callback properties or application data associated with graphics objects. The copied object has callbacks set to empty character arrays and application data set to empty structure arrays. Copies of objects might not behave as expected. For example, clicking a push button on the copy of a uicontrol has no effect.
If you want to create a copy of an object that has callbacks, then rerun the code used to create the first object to create a second object.
If you have existing code that uses 'copyobj' to copy callbacks, then you can use 'copyobj' with the 'legacy' option, for example,
c = copyobj(h,p,'legacy').
The behavior of the 'legacy' option is consistent with versions of MATLAB® before R2014b.


Sign in to comment.