From: Kuldeep Mynampati on
Hi All,

I have created slider in MATLAB in GUI. I have about 100 image files. I was implementing slider to display images when moved back & forward.

My code:

SliderStep = [0.01 0.1];
Min = 1;
Max = 100;
sliderVal = round(get(hObject, 'Value'));
set(hObject, 'Value', sliderVal);

My problem is when ever I move the file the slider. It shows either Min/Max is out of range and slider gets disabled or not shown in GUI.

Please help.

Regards,
Kuldeep
From: RG on
"Kuldeep Mynampati" <mynampatikuldeep(a)gmail.com> wrote in message <ht3kpc$7a8$1(a)fred.mathworks.com>...
> Hi All,
>
> I have created slider in MATLAB in GUI. I have about 100 image files. I was implementing slider to display images when moved back & forward.
>
> My code:
>
> SliderStep = [0.01 0.1];
> Min = 1;
> Max = 100;
> sliderVal = round(get(hObject, 'Value'));
> set(hObject, 'Value', sliderVal);
>
> My problem is when ever I move the file the slider. It shows either Min/Max is out of range and slider gets disabled or not shown in GUI.
>
> Please help.
>
> Regards,
> Kuldeep

Hi Kuldeep,

You define the slider step and max / min, but you never actually assign those values to the properties of your object. You'll need to add a few lines of code:
set(hObject, 'SliderStep', SliderStep);
set(hObject, 'Min', Min);
set(hObject, 'Max', Max);

Hopefully that will work for you.
From: Steven Lord on

"RG " <be.ka.hg(a)gmail.com> wrote in message
news:ht3l6v$51u$1(a)fred.mathworks.com...
> "Kuldeep Mynampati" <mynampatikuldeep(a)gmail.com> wrote in message
> <ht3kpc$7a8$1(a)fred.mathworks.com>...
>> Hi All,
>>
>> I have created slider in MATLAB in GUI. I have about 100 image files. I
>> was implementing slider to display images when moved back & forward. My
>> code:
>>
>> SliderStep = [0.01 0.1];
>> Min = 1;
>> Max = 100;
>> sliderVal = round(get(hObject, 'Value'));
>> set(hObject, 'Value', sliderVal);
>>
>> My problem is when ever I move the file the slider. It shows either
>> Min/Max is out of range and slider gets disabled or not shown in GUI.
>>
>> Please help.
>>
>> Regards,
>> Kuldeep
>
> Hi Kuldeep,
>
> You define the slider step and max / min, but you never actually assign
> those values to the properties of your object. You'll need to add a few
> lines of code:
> set(hObject, 'SliderStep', SliderStep);
> set(hObject, 'Min', Min);
> set(hObject, 'Max', Max);

Set all three of these properties, as well as a starting value for the
position of the slider (which must be between Min and Max inclusive) in one
call to SET.

set(hObject, 'SliderStep', SliderStep, ...
'Min', Min, ...
'Max', Max, ...
'Value', Min); % or Max, or (Min+Max)/2, or some other value where Min
<= value and value <= Max is satisfied.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com