Set default value for slider in MATLAB
조회 수: 6 (최근 30일)
이전 댓글 표시
I'm trying to set a default value for my slider, but for some reason the handle value is not equal to that of the slider. I tried setting it in the CreateFcn function and then calling it back in my main function, but for some reason it's not being saved in handles.
set(gcbo,'Value',1)
handles.fuel_slider1 = get(gcbo,'Value')*100
assignin('base','handles',handles);
guidata(hObject,handles);
neither assigning nor guidata will retain the handles value and I can't call it anywhere.
I basically need to set 6 sliders to 100% and have those values be available in handles. Currently it returns the actual handle 'code' value or whatever it's called (fuel_slider2: 720.0043)
Any ideas?
thanks!
댓글 수: 0
답변 (1개)
Sean de Wolski
2012년 10월 24일
This is why I avoid using gcbo. Explicitly set the handles.sliderx value.
set(handles.slider1,'Value',get(handles.slider1,'Max'));
And I recommend against using assignin. Instead use a breakpoint to debug this inside of the GUI if necessary.
참고 항목
카테고리
Help Center 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!