matlab:如何动态设置可见内容不可见
我有一个关于 matlab 使用接口的简单问题。
我发现,如果我首先声明一个对象(例如带有命令 UI 表的表)不可见,并且在使其可见后,它就会起作用,即我在图中有效地看到了修改。
相反,这是我的问题,如果我首先声明一个对象可见,然后将其设为不可见,则它不起作用,即我无法获得该对象的不可见性。
举个例子:
figure;
h_tabell=uitable(gcf,'vis','off','data',randn(3));
h_tabell=uitable(gcf,'vis','on','data',randn(3)); %
在这里我看到该表现在可见
%现在我想让该表再次不可见,使用 set(h_tabell,'vis','off') %
这里我看到表格已经可见
我需要它,因为在我的程序中,对象是可见的,如果用户需要,我想要to 将同一对象设置为不可见。
有人可以帮助我吗?
I have a simple question about matlab using interface.
I found that if I first declare an object (for example a table with the command UI table) NOT visible and after I make it visible, it works i.e. I see effectively in the figure the modification.
On the contrary, and here it's my problem, If I first declare an object visible and after I make it NOT visible, it doesn't work i.e. I not obtain the invisibility of the object.
Making an example:
figure;
h_tabell=uitable(gcf,'vis','off','data',randn(3));
h_tabell=uitable(gcf,'vis','on','data',randn(3)); %
here I see that the table is now visible
%Now I want make it that table invisible again, withset(h_tabell,'vis','off') %
here I see that the table already is visible
I need it, because in my program, the object is visible and if the user needs, I want to to set invisible the same object.
Anybody can help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该只使用 Matlab 函数
set
来更改对象的属性。在这里,您对
uitable
进行了两次调用,因此如果您将其分解,实际会发生以下情况:h_tabell
code> 与新句柄)但这次可见您可以通过检查您的图窗现在是否有两个子项来验证这一点:
现在,如果您尝试更改句柄 h_tabell 引用的对象的可见属性,它将仅适用于第二个桌子。
以下代码按预期工作并仅创建一个表:
You should only use the Matlab function
set
to change the properties of your object.Here you make two calls to
uitable
, so here is what really happen if you break it down:h_tabell
with the new handle) but this time visibleYou can verify this by checking that your figure now have two children:
Now if you try to change the visible property of the object referenced by the handle h_tabell, it will only apply to the second table.
The following piece of code works as expected and create only one table: