axes对象的句柄会消失,即首次调用有效,第二次就出现

axes对象的句柄会消失,即首次调用有效,第二次就从handles里边消失了,于是报错:


Answer:


This behavior is the result of a combination of the side effects of PLOT, the axes' "NextPlot" property, and the use of GUIHANDLES.



PLOT makes a call to the NEWPLOT function to determine which axes to use. Also, depending on the axes' "NextPlot" property, some of that axes' properties may be set to default values. If the property has the value "Replace", it will reset all of the axes' properties and delete all of the children of the axes. This includes the axes' "Tag" property, set to an empty string. If the "NextPlot" property is set to "ReplaceChildren", then NEWPLOT will only delete the axes' children and will not change the axes' other properties.


GUIHANDLES creates a structure containing the handles for all figure objects having a non-empty "Tag" value (thus having a valid fieldname for a structure). Since the axes' Tag will be an empty string after plotting, it will not be included in the handles structure that is output by GUIHANDLES.


There are two ways around this problem:


1) Do not use GUIHANDLES to get the "handles" structure. If you are using GUIDE and are working in a GUIDE-generated callback function, the "handles" structure will already exist as an input to the function. Also, GUIHANDLES is only intended for use in initializing the GUI. After the GUI is initialized, use the GUIDATA function to get the "handles" structure since the structure may be modified.


2) Set the axes' NextPlot property to 'replacechildren'. This way, the axes' Tag property won't be changed when PLOT calls NEWPLOT.





相关链接:http://www.ilovematlab.cn/thread-55768-1-1.html

http://cn.mathworks.com/matlabcentral/answers/160806-gui-reference-to-non-existent-field-axes1

http://cn.mathworks.com/matlabcentral/newsreader/view_thread/289093


原博客链接:
https://blog.csdn.net/niumengxy/article/details/51392293

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值