Uses of handles value in GUI

4 vues (au cours des 30 derniers jours)
Clément P
Clément P le 9 Mar 2016
Commenté : Clément P le 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 :

Réponses (1)

Mathieu
Mathieu le 9 Mar 2016
Modifié(e) : Mathieu le 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 commentaire
Clément P
Clément P le 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by