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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by