Limited no. of points in a slider?

1 回表示 (過去 30 日間)
Irina Vermesan
Irina Vermesan 2017 年 10 月 2 日
コメント済み: Irina Vermesan 2017 年 10 月 3 日
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 Center および File ExchangeAutomotive についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by