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

6 次查看(过去 30 天)
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);

采纳的回答

MathWorks Support Team
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 个评论
Image Analyst
Image Analyst 2020-4-23
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;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2010b

Community Treasure Hunt

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

Start Hunting!

Translated by