From: Weston Thompson on

Hello all,

Does anyone know how I can set my Slider min and max values from within the CreateFcn? I would like them to be assigned by a variable, so setting them from the .fig doesn't seem to work. Here's what I have now: (tt is the variable)


function slider1_CreateFcn(hObject, eventdata, handles)
set(handles.slider1,'Max',tt-1,'Min',1) %This was just a guess at how to go about it


But I get an error "??? Attempt to reference field of non-structure array"
Please let me know if you know the correct way to do this

Thanks,
Wes
From: Walter Roberson on
Weston Thompson wrote:

> Does anyone know how I can set my Slider min and max values from within
> the CreateFcn? I would like them to be assigned by a variable, so
> setting them from the .fig doesn't seem to work. Here's what I have
> now: (tt is the variable)
>
>
> function slider1_CreateFcn(hObject, eventdata, handles)
> set(handles.slider1,'Max',tt-1,'Min',1) %This was just a guess at how
> to go about it
>
>
> But I get an error "??? Attempt to reference field of non-structure array"
> Please let me know if you know the correct way to do this

That probably indicates that handles is not a structure at that point. You may
wish to put in a breakpoint and examine its value.

Sorry, I do not know what it likely is instead, as I have not used GUIDE much
at all.
From: Matt Fig on
Use hObject.
From: Weston Thompson on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hurioq$2li$1(a)fred.mathworks.com>...
> Use hObject.

Thanks for the replies! This is what I ended up doing


function slider1_CreateFcn(hObject, eventdata, handles)

tt = evalin('base','tt');
set(hObject,'Max',tt-1,'Min',1)
set(hObject,'SliderStep',[1/(tt-1) 0.1])


And that edited both the min/max values and the step which also has to be edited each time the difference between min and max change. Thanks again!

-Weston