increasing slider value of a GUI

1 visualización (últimos 30 días)
Yassine Zaafouri
Yassine Zaafouri el 15 de Feb. de 2017
Editada: Yassine Zaafouri el 16 de Feb. de 2017
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

Respuesta aceptada

Jan
Jan el 15 de Feb. de 2017
Editada: Jan el 15 de Feb. de 2017
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 comentario
Yassine Zaafouri
Yassine Zaafouri el 16 de Feb. de 2017
Editada: Yassine Zaafouri el 16 de Feb. de 2017
Thank you verry much !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by