Change visibility of a frame with a push button

5 Ansichten (letzte 30 Tage)
Robert Eisenbecker
Robert Eisenbecker am 17 Okt. 2017
Hello! My task is to change the visibility of a frame with a push button. If the frame is visible, clicking the button should make it invisible and vice versa. Here is the code of the callback function for the pushbutton.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
visibility = get(handles.uibuttongroup5, 'Visible')
if visibility == 'on'
set(handles.uibuttongroup5, 'Visible', 'off')
else
set(handles.uibuttongroup5, 'Visible', 'on')
end
And I am getting this error:
Matrix dimensions must agree.
Error in guiassign>pushbutton4_Callback (line 346)
if visibility == 'on'
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in guiassign (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)guiassign('pushbutton4_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
>>
Can someone help me with that please?
Thank you!

Akzeptierte Antwort

Stephen23
Stephen23 am 17 Okt. 2017
Bearbeitet: Stephen23 am 17 Okt. 2017
You should use strcmpi to compare, not logical equivalence (which compares arrays element-wise):
if strcmpi(visibility,'on')

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks 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