How can I get the different values from a slider?

조회 수: 1 (최근 30일)
Mayssa
Mayssa 2015년 3월 13일
댓글: Image Analyst 2015년 3월 15일
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
Geoff Hayes
Geoff Hayes 2015년 3월 14일
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.
Mayssa
Mayssa 2015년 3월 15일
well here is my interfac
e, I want to get the value each time when I click on my slider and be read and known by the "binary conversion" button. The issue is I didn't know how to do it. Here are the codes if you want so.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 14일
Why not just use GUIDE and put a slider, then in the callback, do this:
sliderValue = get(handles.slider1, 'Value');
  댓글 수: 2
Mayssa
Mayssa 2015년 3월 15일
I have already worked with uicontrol because I am familiarized with it. I don't really have the time now to learn Guide and repeat all the work. Thank you any way for the tutorial, I will use it if I don't really find a solution for my problem.
Image Analyst
Image Analyst 2015년 3월 15일
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');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by