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?
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:
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');