If you want to copy a plot through the property structure you need to filter out the read only properties (such as Annotation, BeingDeleted, Parent, Type). Is there a way to get a list of read only properties for the object?
The question arose from a related question
How can I plot from a plot handler?
I started to muck around with the previous question, trying to dynamically find out which fields were settable.
I didn't quite get it to work but I could get hold of (most of) the read only properties by using the difference between the return values of set(h) and get(h).
The only property that doesn't show up here is the Parent-property which is settable but is not supposed to be changed in the previous question.
Here is how I got the non-settable properties:
h = plot(1:0.2:10);
xx=get(h)
close all
h2 = plot(0);
settableHandles = set(h2);
settableNames = fieldnames(settableHandles);
allHandles = get(h2);
allNames = fieldnames(allHandles);
nonSettableHandles = rmfield(allHandles,settableNames);
nonSettableNames = fieldnames(nonSettableHandles)
This produces a cell of nonSettableNames:
nonSettableNames =
'Annotation'
'BeingDeleted'
'Type'
why not use something like
try
%// [set property]
catch ME
if ~isempty( regexp(ME.error, 'read only') )
continue;
else
%// [handle other error]
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With