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

6 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 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 Commento
Image Analyst
Image Analyst il 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;

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2010b

Community Treasure Hunt

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

Start Hunting!

Translated by