GUI--how to program two sliders to be dependent on each other
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have made a gui with two sliders that I need to be dependent on each other. I have an equation that relates them (slider1=slider2/.156). I want to be able to move either slider and have the other slider move automatically based on this formula.
I have not programmed the sliders to work correctly, so if anything, I would love some help getting my sliders programmed.
thanks!
0 commentaires
Réponse acceptée
Paulo Silva
le 6 Juin 2011
Suppose your are using GUIDE, on the slider2 callback
set(handles.slider1,'value',get(handles.slider2,'value')/.156)
if not using GUIDE just replace handles.slider1 by the slider1 handle
Simple example, move the slider of the bottom and watch the one in the top, please be carefull with the values.
hf=figure;
sh2 = uicontrol(hf,'Style','slider',...
'Max',1,'Min',0,'Value',0.1,...
'SliderStep',[0.05 0.2],...
'Position',[30 20 150 30],...
'Callback','set(sh1,''value'',get(sh2,''value'')/.156)');
sh1 = uicontrol(hf,'Style','slider',...
'Max',10,'Min',0,'Value',5,...
'SliderStep',[0.05 0.2],...
'Position',[30 90 150 30]);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps 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!