From: Matt Sodomsky on
I actually just came across the same problem. I was creating a dicom image viewer and my sliderstep worked fine, but, if I dragged the slider I would not get integer values. All I needed to do was round the value using this line of code val = round(get(source,'Value')); and it worked fine.

Thanks

Matt

"Steven Lord" <slord(a)mathworks.com> wrote in message <h435vt$pdd$1(a)fred.mathworks.com>...
>
> "James " <jamesmccurley(a)csufresno.edu> wrote in message
> news:h42u5h$5mu$1(a)fred.mathworks.com...
> > Simple slider question. I have a few sliders which cycle through slices in
> > images. The callback for the slider gets the value it is currently at,
> > rounds it to the nearest integer, then is used to index an image. However,
> > if the user drags the slider to a value less than 1 (or 0.5 for round), it
> > returns an error because there is no 0th slice.
>
> Set the Min, Max and SliderStep properties of the slider to appropriate
> values to prevent the slider from stopping on a non-integer step, and set
> the Value property to be a value between Min and Max inclusive. This won't
> prevent all possible problems, but it will prevent a number of them.
>
> > So to fix that, I want to add the conditional statement at the beginning
> > of my slider callback that if the value of the slider is < 1, it makes the
> > value 1.
> >
> > function slidercallback
> >
> > if get(handleSlider,'Value') < 1
> > set(handleSlider,'Value') = 1;
> > end
> > .....
> >
> > end
> >
> > However, whenever I run this I get: ??? Subscript indices must either be
> > real positive integers or logicals.
> >
> > Any ideas?
>
> That doesn't solve all the problems either. You want the Value property to
> be a positive integer value so you probably want a combination of MAX, MIN,
> and ROUND in that situation (MAX to prevent it from being 0 or below, MIN to
> prevent it from being greater than the number of images, and ROUND to make
> it an integer value.
>
> --
> Steve Lord
> slord(a)mathworks.com
>