matlab:如何动态设置可见内容不可见

发布于 2024-12-23 15:15:03 字数 484 浏览 6 评论 0原文

我有一个关于 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, with
set(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2024-12-30 15:15:03

您应该只使用 Matlab 函数 set 来更改对象的属性。

在这里,您对 uitable 进行了两次调用,因此如果您将其分解,实际会发生以下情况:

  • 第一个调用创建一个不可见的表,
  • 第二个调用创建另一个表(覆盖变量 h_tabell code> 与新句柄)但这次可见

您可以通过检查您的图窗现在是否有两个子项来验证这一点:

children=get(gcf,'children');

现在,如果您尝试更改句柄 h_tabell 引用的对象的可见属性,它将仅适用于第二个桌子。

以下代码按预期工作并仅创建一个表:

figure;
h_tabell=uitable(gcf,'visible','off','data',randn(3));
% Switch the table to visible
set(h_tabell,'visible','on');
% Switch it back to invisible
set(h_tabell,'visible','off');

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:

  • the first call create an invisible table
  • the second call create another table (overwriting the variable h_tabell with the new handle) but this time visible

You can verify this by checking that your figure now have two children:

children=get(gcf,'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:

figure;
h_tabell=uitable(gcf,'visible','off','data',randn(3));
% Switch the table to visible
set(h_tabell,'visible','on');
% Switch it back to invisible
set(h_tabell,'visible','off');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文