获取图的只读属性名称列表 [英] Get a list of read only property names for a plot

查看:33
本文介绍了获取图的只读属性名称列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要通过属性结构复制图,则需要过滤掉只读属性(例如,注释,被删除,父项,类型).有没有办法获取对象的只读属性的列表?

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

如何从绘图处理程序进行绘图?

推荐答案

我开始考虑前面的问题,试图动态找出可设置的字段.

I started to muck around with the previous question, trying to dynamically find out which fields were settable.

我不是很想让它工作,但是我可以通过使用set(h)get(h)的返回值之间的差来掌握(大多数)只读属性.

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).

这里唯一没有显示的属性是Parent -property,它是可设置的,但在上一个问题中不应更改.

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)

这将产生一个nonSettableNames单元格:

nonSettableNames = 

    'Annotation'
    'BeingDeleted'
    'Type'

这篇关于获取图的只读属性名称列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆