Borrar filtros
Borrar filtros

GUI--how to program two sliders to be dependent on each other

6 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Paulo Silva
Paulo Silva el 6 de Jun. de 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]);

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by