Get a list of read-only property names for the plot

If you want to copy the plot through a property structure, you need to filter read-only properties (such as Annotation, BeingDeleted, Parent, Type). Is there a way to get a list of read-only properties for an object?

The question arose from a related question.

How can I plot from a plot handler?

+6
source share
2 answers

I began to trick the previous question, trying to dynamically figure out which fields can be set.

I was not able to get it to work, but I was able to get (most) read-only properties using the difference between the returned values โ€‹โ€‹of set(h) and get(h) .

The only property that does not appear here is Parent -property, which is customizable but should not be changed in the previous question.

This is how I got the non-selectable 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 creates a nonSettableNames cell:

 nonSettableNames = 'Annotation' 'BeingDeleted' 'Type' 
+6
source

why not use something like

 try %// [set property] catch ME if ~isempty( regexp(ME.error, 'read only') ) continue; else %// [handle other error] end end 
+2
source

All Articles