フィルターのクリア

how to set a default value for the slider?

5 ビュー (過去 30 日間)
Manoj Kumar
Manoj Kumar 2014 年 7 月 25 日
編集済み: Geoff Hayes 2014 年 7 月 25 日
Hi, I use slider for thresholding the image.
I used text box to get the values of both the sliders. The default value for slider("high") is 255. The problem I am facing is when I don't move the slider("high") I am unable to get the value. But when I vary the slider, I could get the value in the text box.
Can you help me in how to assign a default value in the text box even if i do not move the slider("high").
I tried in many ways, but none of them are working.
if length(level2)==255
level2=255;
else
level2=level2;
end
also I tried with
if (nargin==255) || isempty(level2)
level2=255;
else
level2=level2;
end
Any help is appreciated
thanks...

回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 7 月 25 日
編集済み: Geoff Hayes 2014 年 7 月 25 日
If your default value for the slider is 255, then why not just set this value in the text box. You could do this in the opening function of your GUID (assuming that you are using GUIDE).
Suppose that slider1 is the name of the slider, text1 is the name of the text box, and myGui is the name of the GUI. Then
function myGui_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for myGui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% get the default value for the slider
defVal = get(handles.slider1,'Value');
% set this value in the text box
set(handles.text1,'String',num2str(defVal));
Try the above and see what happens!

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by