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

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

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 5 de Nov. de 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 comentario
Image Analyst
Image Analyst el 23 de Abr. de 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;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2010b

Community Treasure Hunt

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

Start Hunting!

Translated by