increasing slider value of a GUI

조회 수: 1 (최근 30일)
Yassine Zaafouri
Yassine Zaafouri 2017년 2월 15일
편집: Yassine Zaafouri 2017년 2월 16일
i want to increment the value of my slider with a 10 unit step when the user clicks on an arrow at the ends of the scrollbar: [10:10:300]
How can I do this with the Property Inspector ?
thank you

채택된 답변

Jan
Jan 2017년 2월 15일
편집: Jan 2017년 2월 15일
figure;
uicontrol('Style', 'Slider', 'Position', [10, 10, 200,20], ...
'SliderStep', [1/29, 0.1], ...
'Min', 10, 'Max', 300, 'Value', 10, ...
'Callback', 'disp(get(gcbo, ''Value''))')
The range goes from 10 to 300, which is a distance of 290. To get a stepsize of 10, the SliderStep must be 10/290, or 1/29. You should expect rounding errors, so fix the value in the callback:
uicontrol('Style', 'Slider', 'Position', [10, 10, 200,20], ...
'SliderStep', [1/29, 0.1], ...
'Min', 10, 'Max', 300, 'Value', 10, ...
'Callback', mySliderCB);
function mySliderCB(SliderH, EventData)
Value = round(get(SliderH, 'Value'));
set(SliderH, 'Value', Value);
...
  댓글 수: 1
Yassine Zaafouri
Yassine Zaafouri 2017년 2월 16일
편집: Yassine Zaafouri 2017년 2월 16일
Thank you verry much !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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