Limited no. of points in a slider?

1 次查看(过去 30 天)
Hi All,
I have a slider with these settings: Min = 0, Max = 51000, SliderStep = 0.05 and Value = 51000.
When I press the left arrow, the slider position jumps directly to 50000 (instead of 50999.95). From my tests, it seams that if there are more than 1000000 (Max/SliderStep) points in the slider, the slider does not accurately work.
My questions: is there really a limitation of the no. of the points in the slidebar? Has anyone encounter this issue? If yes, have you found a workaround?
Thank you, Irina
  1 个评论
Jan
Jan 2017-10-2
Note: Instead of explaining in words, what you have a settings in your uicontrol command, it is more useful in the forum, if you post the line of code. Then it is easier to reproduce, what you observe.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2017-10-2
编辑:Jan 2017-10-2
Why do you assume to get the value of 50999.95 when you press the arrow? The steps are the fractions of the available range, not the absolute step width. 0.05 means 5% and I cannot reproduce your observation:
uicontrol('Style', 'Slider', ...
'Min', 0, 'Max', 51000, 'Value', 51000, ...
'SliderStep', [0.05, 0.05], ...
'Callback', @(h,e) disp(get(h, 'Value')))
When I click on the left arrow, I get 48450, which is 51000 - 0.05 * (51000 - 0), as expected, and not 50000. I need 1/51 as SliderStep to obtain a step width of 1000.
For the limitation of the no. of the points, the documentation explains clearly:
Both minorstep and majorstep must be greater than 1e-6, and minorstep
must be less than or equal to majorstep
or
doc uicontrol % -> uicontrol properties -> Slider Step
  1 个评论
Irina Vermesan
Irina Vermesan 2017-10-3
Thanks, Simon, for the answer.
I guess it would have been more clear if I had copied the code (as you initially had suggested :-S ):
set(handles.slider1,'Value', 5.1000e+04);
timeMin = 0;
timeMax = 5.1000e+04;
set(handles.slider1,'Min', timeMin);
set(handles.slider1,'Max', timeMax);
dtTime = timeMax - timeMin;
sliderStepArrow = 0.05/dtTime;
sliderStep(1) = sliderStepArrow;
sliderStep(2) = sliderStepArrow;
set(handles.slider1, 'SliderStep', sliderStep);
So, the slider step is actually set to 0.05/(5.1000e+04-0), this being the reason why I assumed the slider would move with 0.05 step.
In the same time, I have just realized that 0.05/(5.1000e+04-0) < 1e-6, which does not respect the condition from the documentation for the minorstep and majorstep.
Thank you for helping me find the explanation for the malfunctioning. Now, I have to find a workaround ...
Thanks, Irina

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Automotive 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by