Change visibility of a frame with a push button

4 visualizaciones (últimos 30 días)
Robert Eisenbecker
Robert Eisenbecker el 17 de Oct. de 2017
Comentada: Robert Eisenbecker el 17 de Oct. de 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!

Respuesta aceptada

Stephen23
Stephen23 el 17 de Oct. de 2017
Editada: Stephen23 el 17 de Oct. de 2017
You should use strcmpi to compare, not logical equivalence (which compares arrays element-wise):
if strcmpi(visibility,'on')

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by