How to get a value from a Slider function in a Gui to put into another function in the same Gui

1 view (last 30 days)
Hi I'm trying to get the value of the slider function into another function but when i call up the value within the other function it tells me that there are too many outputs
function Spring_Callback(hObject, eventdata, handles)
dx=get(hObject,'Value')
--------- that would return the value I want but when i call it in another function
function Initial_Callback(hObject, eventdata, handles)
dx; <--- it would say that it is undefined
dx=Spring_Callback(hObject, 'Value') <--- this would say that there are too many outputs
thank you

Answers (1)

Image Analyst
Image Analyst on 22 Nov 2014
Don't use hObject. Use the actual known name of the slider. Inside any callback, to get the value of sliders called Initial and Spring, you do this:
initialSliderValue = get(handles.Initial, 'Value');
springSliderValue = get(handles.Spring, 'Value');
That will work with any callback whatsoever.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!