Change visibility of a frame with a push button

4 ビュー (過去 30 日間)
Robert Eisenbecker
Robert Eisenbecker 2017 年 10 月 17 日
コメント済み: Robert Eisenbecker 2017 年 10 月 17 日
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!

採用された回答

Stephen23
Stephen23 2017 年 10 月 17 日
編集済み: Stephen23 2017 年 10 月 17 日
You should use strcmpi to compare, not logical equivalence (which compares arrays element-wise):
if strcmpi(visibility,'on')
  1 件のコメント
Robert Eisenbecker
Robert Eisenbecker 2017 年 10 月 17 日
Thank you very much, working now!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by