필터 지우기
필터 지우기

How do I create a button in a GUI that scrolls through number values?

조회 수: 5 (최근 30일)
Ian Flaherty
Ian Flaherty 2012년 8월 31일
I am trying to create a button that has up/down arrows on the side that will scroll through numbers using a specified step size (the user will change it to arrive at a desired value)
Do I have to use an "edit text" box and add up down arrows or a scroll bar? I am not sure how to do this...
I am trying to scroll through timing values in msec from 0 to +900000
Any help is much appreciated

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 8월 31일
편집: Azzi Abdelmalek 2012년 8월 31일
you can use a "slider" button , and "edit text" to set a "slider step" value
%opening function to set your slider parameters
function answer201_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
set(handles.slider1,'min',0)
set(handles.slider1,'max',10)
set(handles.slider1,'SliderStep',[0.01 0.1]);%minor step=0.01;major step=0.1
% slider function to show slider's value on static text button
function slider1_Callback(hObject, eventdata, handles)
w=get(hObject,'Value');
set(handles.text1,'String',w)
% edit text function to change slider step value
function edit1_Callback(hObject, eventdata, handles)
step=get(hObject,'String')
min=double(get(handles.slider1,'min'))
max=double(get(handles.slider1,'max'))
stepn=str2num(step);
if stepn>min & stepn<max
stepn1=stepn/(max-min) ;
set(handles.slider1,'SliderStep',[stepn1 stepn])
else
set(hObject,'String',num2str((max-min)/10))
end

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by