To set default value of slider in gui

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 5 Lug 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.

Più risposte (0)

Categorie

Scopri di più su Networks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by