To set default value of slider in gui

조회 수: 1 (최근 30일)
Luffy
Luffy 2012년 7월 5일
I want to set default value of slider in gui created by guide.I've tried this,
1)In gui_OpeningFcn , is set default value by,
set(handles.slider1,'Value',5); %(min-0 & max-10 in my case)
Slider disappears & it shows an error:
slider control can not have a Value outside of Min/Max range
Control will not be rendered until all of its parameter values are valid
2)Seeing that 1) did not work, I then tried in slider1_CreateFcn
handles.slider1 = gcbo;
set(gcbo,'Value',5);
Even now similar error appears.

채택된 답변

Walter Roberson
Walter Roberson 2012년 7월 5일
It looks likely to me that the Max property of the slider is not getting set until after you try to set the Value, so your Value is being interpreted as being outside the default range Min = 0 to Max = 1. Set the Max at the same time you set the Value. If you do not know a minimum value for the Max then you should not be setting the Value before you know that the upper bound will be at least as large as your desired default Value.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by