To set default value of slider in gui
19 views (last 30 days)
Show older comments
Luffy on 5 Jul 2012
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;
Even now similar error appears.
Walter Roberson on 5 Jul 2012
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.
More Answers (0)
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!