problem with using if statements

i have 2 options in popupmenu and both of the options has 2 panels which contain pushbutton. when i select option1, the pushbutton in panel2 is disabled..when i select option2, the pushbutton in panel1 is disabled.
v=get(handles.selectGroup, 'Value');
switch v
case 1
set(handles.capturecolorButton,'Enable','off');
set(handles.ROI2Button,'Enable','on');
case 2
set(handles.capturecolorButton,'Enable','on');
set(handles.ROI2Button,'Enable','off');
otherwise
end;
what can be corrected?

댓글 수: 6

Arthur
Arthur 2012년 11월 6일
What it the problem? This code seems correct to me.
joanna
joanna 2012년 11월 6일
the first option in the popupmenu is "real-time" and the 2nd is "offline". when i select either of them, nothing happens
Arthur
Arthur 2012년 11월 6일
do you get an error? Did you try to step through the script line for line?
joanna
joanna 2012년 11월 6일
i got an error here:
v=get(handles.selectGroup, 'Value');
where "selectgroup" is the Tag for the popupmenu
Arthur
Arthur 2012년 11월 6일
Please copy the entire error message you get, we're shooting in the dark here....
joanna
joanna 2012년 11월 6일
??? Attempt to reference field of non-structure array.
Error in ==> capture>selectGroup_CreateFcn at 464 v=get(handles.selectGroup, 'Value');
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> capture at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)capture('selectGroup_CreateFcn',hObject,eventdata,guidata(hObject))
??? Error using ==> struct2handle Error while evaluating uicontrol CreateFcn

댓글을 달려면 로그인하십시오.

 채택된 답변

Arthur
Arthur 2012년 11월 6일

0 개 추천

You placed the code intothe CreateFcn of te popup. This means the code is only executed when the popup is created, not when you press it. Cut and paste the code into the CallbackFcn of the popup, and it probably works.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2012년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by