Uses of handles value in GUI

15 views (last 30 days)
Clément P
Clément P on 9 Mar 2016
Commented: Clément P on 10 Mar 2016
Hello,
I'm having trouble using GUIDE.
I'm currently working on an interface with togglebuttons and axes. I would like to reset properly the axes properties when pushing back togglebuttons.
Each of my 3 togglebuttons plot curves on the axis. I would like my axes properties to reset when I pushback the togglebutton and when there is no other curve on the axes (= when other toggebuttons value are 0).
This is a part of the code on my togglebutton1_Callback function :
if get(hObject,'Value')
grid on; hold all; box on; set(gca,'fontsize',11,'FontName','Garamond');
xlabel('Déformation [mm/mm]','fontsize',14)
ylabel('Module de Young [GPa]','fontsize',14)
axis([0,inf,0,150])
for i=1:handles.n
handles.h3(i)=plot(handles.X1(:,i),handles.Z(:,i),'.'); %Curve
handles.h4(i)=handles.essais(i).SpecID; %For legend, currently not used
iscell(handles.h2(i));
end;
else
set(handles.h3(:),'Visible','off');
if handles.togglebutton2==0 && handles.togglebutton3==0
reset(handles.axes1);
end
end
guidata(hObject,handles);
handles.h3(:) is the handle referring to the plot, containing severals curves.
I have some trouble with this. The handles have different values at the beginning : (=> not equal to 0)
  • togglebutton1=180.0065
  • togglebutton 2=181.0065
  • togglebutton3=182.0065
  • axes1=174.0065.
Where do the values come from? Do I have to set all the handles to zero first in the openingFct function? And how?
(Sorry for my English, it's not my native langage).
See my .fig below :

Answers (1)

Mathieu
Mathieu on 9 Mar 2016
Edited: Mathieu on 9 Mar 2016
Hello,
It is normal your three togglebuttons have different handles. It is like this Matlab know what object is used during an event (for example when you push your button). It is the same for all the curve in your axe, each one have different handles.
I assume your axe is named h3, so you try to hide your axe before to clean it?
Personnally, I designed a GUI in which I clean all my axes with cla and not reset because the function is made for axes.
For me, h3(:) contains all the properties of your axe, including the curves (as children). So if you want to clean your axe, for me you just have to do cla(h3, 'reset') to reset all properties of your axe as the beginning.
  1 Comment
Clément P
Clément P on 10 Mar 2016
Hi Mathieu,
Thanks for your answer. So these values are set arbitrary by Matlab?
In fact, I also have check boxes which plot some curves that I want to keep on the axes, except if the 3 plots from togglebuttons are not presents, ie togglebuton's value=0.
My axe's handle is axes1, and h3(:) refers to the plot which contains several curves. My idea was to turn the visibility of h3(:), ie of the curves, off, and keep the other curves on the axes1.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!