GUI--how to program two sliders to be dependent on each other
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Paulo Silva
on 6 Jun 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 Comments
More Answers (0)
See Also
Categories
Find more on Debugging and Analysis 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!