Why does my slider disappear when I change the Min and Max properties?

7 views (last 30 days)
When I create a slider and set the Min property of the slider to 1 and the Max property to 10, my slider disappears. Why does it disappear and how do I get it to reappear?
u = uicontrol('Style', 'slider');
set(u, 'Min', 1, 'Max', 10);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 5 Nov 2010
There are two reasons why the slider can disappear when you change the Min and Max properties.
1) The Value property of the slider is no longer between the Min property and the Max property. If this is the case, change the Min, Max, and Value properties so that the Min property is less than or equal to the Value property, which is less than or equal to the Max property:
u = uicontrol('Style', 'slider');
set(u, 'Min', 1, 'Max', 10, 'Value', 1);
2) The Max property of the slider is less than or equal to the Min property of the slider. To correct this, change the Min property and/or the Max property of the slider so that the Min property is strictly less than the Max property.
  1 Comment
Image Analyst
Image Analyst on 23 Apr 2020
If you want to set the min, max, and value all to the same value, then do this:
u.Min = value;
u.Max = value;
u.Value = value;
If you're using GUIDE, then u should be replaced by handles dot (the tag name of the slider), like handles.sldMySlider.
handles.sldMySlider.Min = value;
handles.sldMySlider.Max = value;
handles.sldMySlider.Value = value;

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2010b

Community Treasure Hunt

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

Start Hunting!