Filter löschen
Filter löschen

How to toggle: Making uicontrols (in)visible

7 Ansichten (letzte 30 Tage)
Hello kity
Hello kity am 31 Dez. 2012
Hi
I want to make a couple edit fields and static texts visible and invisible by using a button/toggle button. But how to do that?
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
set(handles.Edit1,'Visible','off')
elseif button_state == get(hObject,'Min')
set(Edit1,'Visible','on')
% Toggle button is not pressed-take appropriate action
...
end

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 31 Dez. 2012
Bearbeitet: Azzi Abdelmalek am 31 Dez. 2012
% you've written 'Edit1' instead of 'handles.Edit1'
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
set(handles.Edit1,'Visible','off')
elseif button_state == get(hObject,'Min')
set(handles.Edit1,'Visible','on')
end
  2 Kommentare
Hello kity
Hello kity am 2 Jan. 2013
Bearbeitet: Hello kity am 2 Jan. 2013
how can i make that edit1 field a NaN if the edit field is not visible?
str2double(get(handles.Edit1,'String'))=NaN;
Azzi Abdelmalek
Azzi Abdelmalek am 2 Jan. 2013
Why are you using get?
set(handles.Edit1,'string','nan')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by