How can I get the different values from a slider?
1 view (last 30 days)
Show older comments
I am working on uiconrol and I need to get the values from the slider so I can use it in onother script as a threshold to convert an image to a binary one. I have used n=get (s,'value') and n as a global var but it didn't work.
s =uicontrol('Style', 'slider','Min',0.01,'Max',1,'Value',0.01,'Position', [1030 420 90 20]);
2 Comments
Geoff Hayes
on 14 Mar 2015
Mayssa - how are you providing the value of the slider to the other script? Since you don't have a callback for the slider, at what point do you decide to pass this value on? Do you press a button or do something else? Please provide more details.
Answers (1)
Image Analyst
on 14 Mar 2015
Why not just use GUIDE and put a slider, then in the callback, do this:
sliderValue = get(handles.slider1, 'Value');
Here's a nice framework you can get started with: http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
2 Comments
Image Analyst
on 15 Mar 2015
OK fine - you like to do things the hard way and build your GUI from scratch by specifying all the tedious details. But what about my suggestion to get the slider value? It will work regardless of how much work you put into creating your slider.
sliderValue = get(handleToYourSlider, 'Value');
See Also
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!